diff options
author | Henner Zeller <h.zeller@acm.org> | 2022-06-06 13:03:47 -0700 |
---|---|---|
committer | Lofty <dan.ravensloft@gmail.com> | 2022-06-09 16:07:45 +0100 |
commit | 9c41b431917fe623b81e0120b1e7cb119f710b78 (patch) | |
tree | a31cb6741b653ff82d28e3481be0ce0aee4ebd37 | |
parent | 9d41aa8e2888577fc2a57179b8d4a9a3a4e03f59 (diff) | |
download | yosys-9c41b431917fe623b81e0120b1e7cb119f710b78.tar.gz yosys-9c41b431917fe623b81e0120b1e7cb119f710b78.tar.bz2 yosys-9c41b431917fe623b81e0120b1e7cb119f710b78.zip |
Use compiler-generated default constructor for RTLIL::Const::Const
No need for a manual implementation.
While at it: have the constructor that takes a string take a
const string reference instead to avoid a copy.
-rw-r--r-- | kernel/rtlil.cc | 10 | ||||
-rw-r--r-- | kernel/rtlil.h | 4 |
2 files changed, 3 insertions, 11 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 72dcb89af..8346b56e0 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -204,7 +204,7 @@ RTLIL::Const::Const() flags = RTLIL::CONST_FLAG_NONE; } -RTLIL::Const::Const(std::string str) +RTLIL::Const::Const(const std::string &str) { flags = RTLIL::CONST_FLAG_STRING; bits.reserve(str.size() * 8); @@ -243,14 +243,6 @@ RTLIL::Const::Const(const std::vector<bool> &bits) this->bits.emplace_back(b ? State::S1 : State::S0); } -RTLIL::Const::Const(const RTLIL::Const &c) -{ - flags = c.flags; - this->bits.reserve(c.size()); - for (const auto &b : c.bits) - this->bits.push_back(b); -} - bool RTLIL::Const::operator <(const RTLIL::Const &other) const { if (bits.size() != other.bits.size()) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index d8300f159..7a0b6b9c7 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -636,12 +636,12 @@ struct RTLIL::Const std::vector<RTLIL::State> bits; Const(); - Const(std::string str); + Const(const std::string &str); Const(int val, int width = 32); Const(RTLIL::State bit, int width = 1); Const(const std::vector<RTLIL::State> &bits) : bits(bits) { flags = CONST_FLAG_NONE; } Const(const std::vector<bool> &bits); - Const(const RTLIL::Const &c); + Const(const RTLIL::Const &c) = default; RTLIL::Const &operator =(const RTLIL::Const &other) = default; bool operator <(const RTLIL::Const &other) const; |