Merge pull request #998 from mdaiter/get_bool_attribute_opts

Minor optimization to get_attribute_bool
This commit is contained in:
Clifford Wolf 2019-05-08 08:34:35 +02:00 committed by GitHub
commit c582a25bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -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)