Skip to content

Commit ba9810e

Browse files
[TableGen] Avoid repeated hash lookups (NFC) (#126464)
1 parent eaedfc0 commit ba9810e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

clang/utils/TableGen/MveEmitter.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,17 +1629,10 @@ void EmitterBase::EmitBuiltinCG(raw_ostream &OS) {
16291629
for (const auto &OI : kv.second)
16301630
key.push_back(OI.ParamValues[i]);
16311631

1632-
auto Found = ParamNumberMap.find(key);
1633-
if (Found != ParamNumberMap.end()) {
1634-
// Yes, an existing parameter variable can be reused for this.
1635-
ParamNumbers.push_back(Found->second);
1636-
continue;
1637-
}
1638-
1639-
// No, we need a new parameter variable.
1640-
int ExistingIndex = ParamNumberMap.size();
1641-
ParamNumberMap[key] = ExistingIndex;
1642-
ParamNumbers.push_back(ExistingIndex);
1632+
// Obtain a new parameter variable if we don't have one.
1633+
int ParamNum =
1634+
ParamNumberMap.try_emplace(key, ParamNumberMap.size()).first->second;
1635+
ParamNumbers.push_back(ParamNum);
16431636
}
16441637

16451638
// Now we're ready to do the pass 2 code generation, which will emit the

0 commit comments

Comments
 (0)