From: Matthew Daiter Date: Wed, 8 May 2019 03:04:28 +0000 (-0500) Subject: Minor optimization to get_attribute_bool X-Git-Tag: yosys-0.9~135^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e629d289515e2792fa644fca105998bd9e366de;p=yosys.git Minor optimization to get_attribute_bool --- 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 &data)