diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-05-08 08:34:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-08 08:34:35 +0200 |
commit | c582a25bdbd657c9d3a91cc627520fd25188fdcc (patch) | |
tree | d539849a0811d5e946f49a6d1c3f442b1482270d | |
parent | b7ec698d4063f0e0ae021050782004c523302b0c (diff) | |
parent | 6e629d289515e2792fa644fca105998bd9e366de (diff) | |
download | yosys-c582a25bdbd657c9d3a91cc627520fd25188fdcc.tar.gz yosys-c582a25bdbd657c9d3a91cc627520fd25188fdcc.tar.bz2 yosys-c582a25bdbd657c9d3a91cc627520fd25188fdcc.zip |
Merge pull request #998 from mdaiter/get_bool_attribute_opts
Minor optimization to get_attribute_bool
-rw-r--r-- | kernel/rtlil.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 147d378e5..79ff4a6a6 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -218,15 +218,19 @@ void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id, bool value) { if (value) attributes[id] = RTLIL::Const(1); - else if (attributes.count(id)) - attributes.erase(id); + else { + const auto it = attributes.find(id); + if (it != attributes.end()) + attributes.erase(it); + } } bool RTLIL::AttrObject::get_bool_attribute(RTLIL::IdString id) const { - if (attributes.count(id) == 0) + const auto it = attributes.find(id); + if (it == attributes.end()) return false; - return attributes.at(id).as_bool(); + return it->second.as_bool(); } void RTLIL::AttrObject::set_strpool_attribute(RTLIL::IdString id, const pool<string> &data) |