mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 10:33:13 +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:
+3
-9
@@ -195,22 +195,18 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
|
||||
for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) {
|
||||
if (AstVar* const oldvarp = VN_CAST(subnodep, Var)) {
|
||||
if (oldvarp->isIO()) {
|
||||
if (ioNames.find(oldvarp->name()) != ioNames.end()) {
|
||||
if (!ioNames.insert(oldvarp->name()).second) {
|
||||
// UINFO(8, "Multitop dup I/O found: " << oldvarp << endl);
|
||||
dupNames.insert(oldvarp->name());
|
||||
} else {
|
||||
ioNames.insert(oldvarp->name());
|
||||
}
|
||||
} else if (v3Global.opt.topIfacesSupported() && oldvarp->isIfaceRef()) {
|
||||
const AstNodeDType* const subtypep = oldvarp->subDTypep();
|
||||
if (VN_IS(subtypep, IfaceRefDType)) {
|
||||
const AstIfaceRefDType* const ifacerefp = VN_AS(subtypep, IfaceRefDType);
|
||||
if (!ifacerefp->cellp()) {
|
||||
if (ioNames.find(oldvarp->name()) != ioNames.end()) {
|
||||
if (!ioNames.insert(oldvarp->name()).second) {
|
||||
// UINFO(8, "Multitop dup interface found: " << oldvarp << endl);
|
||||
dupNames.insert(oldvarp->name());
|
||||
} else {
|
||||
ioNames.insert(oldvarp->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,12 +217,10 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
|
||||
const AstIfaceRefDType* const ifacerefp
|
||||
= VN_AS(arrsubtypep, IfaceRefDType);
|
||||
if (!ifacerefp->cellp()) {
|
||||
if (ioNames.find(oldvarp->name()) != ioNames.end()) {
|
||||
if (!ioNames.insert(oldvarp->name()).second) {
|
||||
// UINFO(8, "Multitop dup interface array found: " << oldvarp
|
||||
// << endl);
|
||||
dupNames.insert(oldvarp->name());
|
||||
} else {
|
||||
ioNames.insert(oldvarp->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user