3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-10-11 02:08:08 +00:00

Make the Const string constructor take the string by value and move it into the const

This commit is contained in:
Robert O'Callahan 2025-09-12 04:57:08 +00:00
parent 7719beb4ae
commit 6b43fca8df
2 changed files with 3 additions and 3 deletions

View file

@ -264,10 +264,10 @@ std::string& Const::get_str() {
return *get_if_str(); return *get_if_str();
} }
RTLIL::Const::Const(const std::string &str) RTLIL::Const::Const(std::string str)
{ {
flags = RTLIL::CONST_FLAG_STRING; flags = RTLIL::CONST_FLAG_STRING;
new ((void*)&str_) std::string(str); new ((void*)&str_) std::string(std::move(str));
tag = backing_tag::string; tag = backing_tag::string;
} }

View file

@ -859,7 +859,7 @@ private:
public: public:
Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector<RTLIL::State>()) {} Const() : flags(RTLIL::CONST_FLAG_NONE), tag(backing_tag::bits), bits_(std::vector<RTLIL::State>()) {}
Const(const std::string &str); Const(std::string str);
Const(long long val); // default width is 32 Const(long long val); // default width is 32
Const(long long val, int width); Const(long long val, int width);
Const(RTLIL::State bit, int width = 1); Const(RTLIL::State bit, int width = 1);