Skip to content

Commit 2d7d74d

Browse files
[LiveDebugValues] Avoid repeated hash lookups (NFC) (#109242)
1 parent 157adcc commit 2d7d74d

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -484,22 +484,16 @@ class DbgOpIDMap {
484484

485485
private:
486486
DbgOpID insertConstOp(MachineOperand &MO) {
487-
auto ExistingIt = ConstOpToID.find(MO);
488-
if (ExistingIt != ConstOpToID.end())
489-
return ExistingIt->second;
490-
DbgOpID ID(true, ConstOps.size());
491-
ConstOpToID.insert(std::make_pair(MO, ID));
492-
ConstOps.push_back(MO);
493-
return ID;
487+
auto [It, Inserted] = ConstOpToID.try_emplace(MO, true, ConstOps.size());
488+
if (Inserted)
489+
ConstOps.push_back(MO);
490+
return It->second;
494491
}
495492
DbgOpID insertValueOp(ValueIDNum VID) {
496-
auto ExistingIt = ValueOpToID.find(VID);
497-
if (ExistingIt != ValueOpToID.end())
498-
return ExistingIt->second;
499-
DbgOpID ID(false, ValueOps.size());
500-
ValueOpToID.insert(std::make_pair(VID, ID));
501-
ValueOps.push_back(VID);
502-
return ID;
493+
auto [It, Inserted] = ValueOpToID.try_emplace(VID, false, ValueOps.size());
494+
if (Inserted)
495+
ValueOps.push_back(VID);
496+
return It->second;
503497
}
504498
};
505499

0 commit comments

Comments
 (0)