Skip to content

Commit c61c888

Browse files
[llvm-mca] Avoid repeated hash lookups (NFC) (#129656)
1 parent a5bbfcf commit c61c888

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/tools/llvm-mca/CodeRegion.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void InstrumentRegions::beginRegion(StringRef Description, SMLoc Loc,
123123
return;
124124
}
125125

126-
auto It = ActiveRegions.find(Description);
127-
if (It != ActiveRegions.end()) {
126+
auto [It, Inserted] = ActiveRegions.try_emplace(Description, Regions.size());
127+
if (!Inserted) {
128128
const CodeRegion &R = *Regions[It->second];
129129
SM.PrintMessage(
130130
Loc, llvm::SourceMgr::DK_Error,
@@ -136,7 +136,6 @@ void InstrumentRegions::beginRegion(StringRef Description, SMLoc Loc,
136136
return;
137137
}
138138

139-
ActiveRegions[Description] = Regions.size();
140139
Regions.emplace_back(
141140
std::make_unique<InstrumentRegion>(Description, Loc, std::move(I)));
142141
}

0 commit comments

Comments
 (0)