Skip to content

Commit 7628fcf

Browse files
[CrossTU] Avoid repeated hash lookups (NFC) (#126380)
1 parent 2fee5ef commit 7628fcf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: clang/lib/CrossTU/CrossTranslationUnit.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,16 @@ CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
453453
return std::move(IndexLoadError);
454454

455455
// Check if there is an entry in the index for the function.
456-
if (!NameFileMap.count(FunctionName)) {
456+
auto It = NameFileMap.find(FunctionName);
457+
if (It == NameFileMap.end()) {
457458
++NumNotInOtherTU;
458459
return llvm::make_error<IndexError>(index_error_code::missing_definition);
459460
}
460461

461462
// Search in the index for the filename where the definition of FunctionName
462463
// resides.
463464
if (llvm::Expected<ASTUnit *> FoundForFile =
464-
getASTUnitForFile(NameFileMap[FunctionName], DisplayCTUProgress)) {
465+
getASTUnitForFile(It->second, DisplayCTUProgress)) {
465466

466467
// Update the cache.
467468
NameASTUnitMap[FunctionName] = *FoundForFile;

0 commit comments

Comments
 (0)