Skip to content

Commit ba52b56

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#140691)
With this patch, we always update Inserted. That's OK because we only read Inserted as shown in this patch. Without this patch, it's a write-only variable.
1 parent 86f2fdd commit ba52b56

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/lib/Analysis/IRSimilarityIdentifier.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,12 +1306,11 @@ static void findCandidateStructures(
13061306
CandIt != CandEndIt; CandIt++) {
13071307

13081308
// Determine if it has an assigned structural group already.
1309-
CandToGroupIt = CandToGroup.find(&*CandIt);
1310-
if (CandToGroupIt == CandToGroup.end()) {
1311-
// If not, we assign it one, and add it to our mapping.
1312-
std::tie(CandToGroupIt, Inserted) =
1313-
CandToGroup.insert(std::make_pair(&*CandIt, CurrentGroupNum++));
1314-
}
1309+
// If not, we assign it one, and add it to our mapping.
1310+
std::tie(CandToGroupIt, Inserted) =
1311+
CandToGroup.try_emplace(&*CandIt, CurrentGroupNum);
1312+
if (Inserted)
1313+
++CurrentGroupNum;
13151314

13161315
// Get the structural group number from the iterator.
13171316
OuterGroupNum = CandToGroupIt->second;

0 commit comments

Comments
 (0)