@@ -30,9 +30,10 @@ class AppIDIndex::ModuleAppIDs {
30
30
// / bubbling up from an instance and is used to inform the conflicting entry
31
31
// / error message.
32
32
LogicalResult add (AppIDAttr id, Operation *op, bool inherited) {
33
- if (childAppIDPaths.find (id) != childAppIDPaths.end ()) {
33
+ auto existingIter = childAppIDPaths.find (id);
34
+ if (existingIter != childAppIDPaths.end ()) {
34
35
return op->emitOpError (" Found multiple identical AppIDs in same module" )
35
- .attachNote (childAppIDPaths[id] ->getLoc ())
36
+ .attachNote (existingIter-> getSecond () ->getLoc ())
36
37
<< " first AppID located here."
37
38
<< (inherited ? " Must insert appid to differentiate one instance "
38
39
" branch from the other."
@@ -222,10 +223,11 @@ FailureOr<ArrayAttr> AppIDIndex::getAppIDPathAttr(hw::HWModuleLike fromMod,
222
223
FailureOr<const AppIDIndex::ModuleAppIDs *>
223
224
AppIDIndex::buildIndexFor (hw::HWModuleLike mod) {
224
225
// Memoize.
225
- ModuleAppIDs *&appIDs = containerAppIDs[mod];
226
- if (appIDs != nullptr )
227
- return appIDs;
228
- appIDs = new ModuleAppIDs ();
226
+ auto appidsIter = containerAppIDs.find (mod);
227
+ if (appidsIter != containerAppIDs.end ())
228
+ return appidsIter->getSecond ();
229
+ ModuleAppIDs *appIDs = new ModuleAppIDs ();
230
+ containerAppIDs.try_emplace (mod, appIDs);
229
231
230
232
auto done = mod.walk ([&](Operation *op) {
231
233
// If an op has an appid attribute, add it to the index and terminate the
0 commit comments