Author: Piotr Zegar
Date: 2023-11-10T18:11:10Z
New Revision: 8909ff6927f856774a907148cadd3af904361601

URL: 
https://github.com/llvm/llvm-project/commit/8909ff6927f856774a907148cadd3af904361601
DIFF: 
https://github.com/llvm/llvm-project/commit/8909ff6927f856774a907148cadd3af904361601.diff

LOG: [clang-tidy][NFC] Reduce map lookups in IncludeSorter

Part of D117460, reduce multiple lookups on map
in IncludeSorter::addInclude method to one.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp 
b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index fe4d2b6d03aa48b..eb21827bdeba3cc 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -134,12 +134,13 @@ void IncludeSorter::addInclude(StringRef FileName, bool 
IsAngled,
   int Offset = findNextLine(SourceMgr->getCharacterData(EndLocation));
 
   // Record the relevant location information for this inclusion directive.
-  IncludeLocations[FileName].push_back(
+  auto &IncludeLocation = IncludeLocations[FileName];
+  IncludeLocation.push_back(
       SourceRange(HashLocation, EndLocation.getLocWithOffset(Offset)));
-  SourceLocations.push_back(IncludeLocations[FileName].back());
+  SourceLocations.push_back(IncludeLocation.back());
 
   // Stop if this inclusion is a duplicate.
-  if (IncludeLocations[FileName].size() > 1)
+  if (IncludeLocation.size() > 1)
     return;
 
   // Add the included file's name to the appropriate bucket.


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to