mirror of
https://github.com/verilator/verilator.git
synced 2026-09-03 06:43:14 +02:00
Avoid double traversal of maps
The typical find/if-not-exists-insert pattern can be achieved with 1 lookup instead of 2 using emplace with a sentinel value. Also maps value initialize their values when inserted with the [] operator, this is defined and so there is no need to explicitly insert zeroes for integer values.
This commit is contained in:
+1
-1
@@ -310,7 +310,7 @@ private:
|
||||
UASSERT_OBJ(varp->attrSplitVar(), varp, " no split_var metacomment");
|
||||
const MapIt it = m_map.find(varp);
|
||||
if (it == m_map.end()) return false; // Not registered
|
||||
const bool ok = m_map[varp].insert(ref).second;
|
||||
const bool ok = it->second.insert(ref).second;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user