Author: Kazu Hirata Date: 2025-02-08T11:36:05-08:00 New Revision: 7628fcf3d43eb20c292ab0dd25ba3f52dba248a6
URL: https://github.com/llvm/llvm-project/commit/7628fcf3d43eb20c292ab0dd25ba3f52dba248a6 DIFF: https://github.com/llvm/llvm-project/commit/7628fcf3d43eb20c292ab0dd25ba3f52dba248a6.diff LOG: [CrossTU] Avoid repeated hash lookups (NFC) (#126380) Added: Modified: clang/lib/CrossTU/CrossTranslationUnit.cpp Removed: ################################################################################ diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp index 9faf2a8a173411..ad2ebb6cd6e6c8 100644 --- a/clang/lib/CrossTU/CrossTranslationUnit.cpp +++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp @@ -453,7 +453,8 @@ CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction( return std::move(IndexLoadError); // Check if there is an entry in the index for the function. - if (!NameFileMap.count(FunctionName)) { + auto It = NameFileMap.find(FunctionName); + if (It == NameFileMap.end()) { ++NumNotInOtherTU; return llvm::make_error<IndexError>(index_error_code::missing_definition); } @@ -461,7 +462,7 @@ CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction( // Search in the index for the filename where the definition of FunctionName // resides. if (llvm::Expected<ASTUnit *> FoundForFile = - getASTUnitForFile(NameFileMap[FunctionName], DisplayCTUProgress)) { + getASTUnitForFile(It->second, DisplayCTUProgress)) { // Update the cache. NameASTUnitMap[FunctionName] = *FoundForFile; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits