Skip to content

Commit 8909ff6

Browse files
committed
[clang-tidy][NFC] Reduce map lookups in IncludeSorter
Part of D117460, reduce multiple lookups on map in IncludeSorter::addInclude method to one.
1 parent 2bac720 commit 8909ff6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ void IncludeSorter::addInclude(StringRef FileName, bool IsAngled,
134134
int Offset = findNextLine(SourceMgr->getCharacterData(EndLocation));
135135

136136
// Record the relevant location information for this inclusion directive.
137-
IncludeLocations[FileName].push_back(
137+
auto &IncludeLocation = IncludeLocations[FileName];
138+
IncludeLocation.push_back(
138139
SourceRange(HashLocation, EndLocation.getLocWithOffset(Offset)));
139-
SourceLocations.push_back(IncludeLocations[FileName].back());
140+
SourceLocations.push_back(IncludeLocation.back());
140141

141142
// Stop if this inclusion is a duplicate.
142-
if (IncludeLocations[FileName].size() > 1)
143+
if (IncludeLocation.size() > 1)
143144
return;
144145

145146
// Add the included file's name to the appropriate bucket.

0 commit comments

Comments
 (0)