diff --git a/src/Type.cc b/src/Type.cc index 4c54c01552..a5d57d187c 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1617,12 +1617,10 @@ zeek_int_t EnumType::Lookup(const string& module_name, const char* name) const { } zeek_int_t EnumType::Lookup(const string& full_name) const { - auto pos = names.find(full_name.c_str()); - - if ( pos == names.end() ) - return -1; - else + if ( auto pos = names.find(full_name.c_str()); pos != names.end() ) return pos->second; + + return -1; } const char* EnumType::Lookup(zeek_int_t value) const { @@ -1641,14 +1639,11 @@ EnumType::enum_name_list EnumType::Names() const { } const EnumValPtr& EnumType::GetEnumVal(zeek_int_t i) { - auto it = vals.find(i); + if ( auto it = vals.find(i); it != vals.end() ) + return it->second; - if ( it == vals.end() ) { - auto ev = make_intrusive(IntrusivePtr{NewRef{}, this}, i); - return vals.emplace(i, std::move(ev)).first->second; - } - - return it->second; + auto ev = make_intrusive(IntrusivePtr{NewRef{}, this}, i); + return vals.emplace(i, std::move(ev)).first->second; } void EnumType::DoDescribe(ODesc* d) const { diff --git a/src/Type.h b/src/Type.h index f5c1456e4a..459ea05472 100644 --- a/src/Type.h +++ b/src/Type.h @@ -869,8 +869,7 @@ protected: // Whether any of the elements of the enum were added via redef's. bool has_redefs = false; - using ValMap = std::unordered_map; - ValMap vals; + std::unordered_map vals; // The counter is initialized to 0 and incremented on every implicit // auto-increment name that gets added (thus its > 0 if