diff options
author | Matthew Daiter <mdaiter8121@gmail.com> | 2019-05-07 22:04:28 -0500 |
---|---|---|
committer | Matthew Daiter <mdaiter8121@gmail.com> | 2019-05-07 22:04:28 -0500 |
commit | 6e629d289515e2792fa644fca105998bd9e366de (patch) | |
tree | 2f6354eee077e6f5b11405006ce864ea7887f618 /kernel | |
parent | 752553d8e91643228714e04d9887d32f5d47870a (diff) | |
download | yosys-6e629d289515e2792fa644fca105998bd9e366de.tar.gz yosys-6e629d289515e2792fa644fca105998bd9e366de.tar.bz2 yosys-6e629d289515e2792fa644fca105998bd9e366de.zip |
Minor optimization to get_attribute_bool
Diffstat (limited to 'kernel')
-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) |