@@ -704,9 +704,10 @@ Optional<FileEntryRef> DirectoryLookup::DoFrameworkLookup(
704
704
}
705
705
706
706
void HeaderSearch::cacheLookupSuccess (LookupFileCacheInfo &CacheLookup,
707
- unsigned HitIdx, SourceLocation Loc) {
708
- CacheLookup.HitIdx = HitIdx;
709
- noteLookupUsage (HitIdx, Loc);
707
+ ConstSearchDirIterator HitIt,
708
+ SourceLocation Loc) {
709
+ CacheLookup.HitIt = HitIt;
710
+ noteLookupUsage (HitIt.Idx , Loc);
710
711
}
711
712
712
713
void HeaderSearch::noteLookupUsage (unsigned HitIdx, SourceLocation Loc) {
@@ -964,25 +965,28 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
964
965
CurDir = nullptr ;
965
966
966
967
// If this is a system #include, ignore the user #include locs.
967
- unsigned i = isAngled ? AngledDirIdx : 0 ;
968
+ ConstSearchDirIterator It =
969
+ isAngled ? angled_dir_begin () : search_dir_begin ();
968
970
969
971
// If this is a #include_next request, start searching after the directory the
970
972
// file was found in.
971
973
if (FromDir)
972
- i = FromDir. Idx ;
974
+ It = FromDir;
973
975
974
976
// Cache all of the lookups performed by this method. Many headers are
975
977
// multiply included, and the "pragma once" optimization prevents them from
976
978
// being relex/pp'd, but they would still have to search through a
977
979
// (potentially huge) series of SearchDirs to find it.
978
980
LookupFileCacheInfo &CacheLookup = LookupFileCache[Filename];
979
981
982
+ ConstSearchDirIterator NextIt = std::next (It);
983
+
980
984
// If the entry has been previously looked up, the first value will be
981
985
// non-zero. If the value is equal to i (the start point of our search), then
982
986
// this is a matching hit.
983
- if (!SkipCache && CacheLookup.StartIdx == i+ 1 ) {
987
+ if (!SkipCache && CacheLookup.StartIt == NextIt ) {
984
988
// Skip querying potentially lots of directories for this lookup.
985
- i = CacheLookup.HitIdx ;
989
+ It = CacheLookup.HitIt ;
986
990
if (CacheLookup.MappedName ) {
987
991
Filename = CacheLookup.MappedName ;
988
992
if (IsMapped)
@@ -992,17 +996,17 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
992
996
// Otherwise, this is the first query, or the previous query didn't match
993
997
// our search start. We will fill in our found location below, so prime the
994
998
// start point value.
995
- CacheLookup.reset (/* StartIdx =*/ i+ 1 );
999
+ CacheLookup.reset (/* NewStartIt =*/ NextIt );
996
1000
}
997
1001
998
1002
SmallString<64 > MappedName;
999
1003
1000
1004
// Check each directory in sequence to see if it contains this file.
1001
- for (; i != SearchDirs. size (); ++i ) {
1005
+ for (; It != search_dir_end (); ++It ) {
1002
1006
bool InUserSpecifiedSystemFramework = false ;
1003
1007
bool IsInHeaderMap = false ;
1004
1008
bool IsFrameworkFoundInDir = false ;
1005
- Optional<FileEntryRef> File = SearchDirs[i]. LookupFile (
1009
+ Optional<FileEntryRef> File = It-> LookupFile (
1006
1010
Filename, *this , IncludeLoc, SearchPath, RelativePath, RequestingModule,
1007
1011
SuggestedModule, InUserSpecifiedSystemFramework, IsFrameworkFoundInDir,
1008
1012
IsInHeaderMap, MappedName);
@@ -1024,7 +1028,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
1024
1028
if (!File)
1025
1029
continue ;
1026
1030
1027
- CurDir = ConstSearchDirIterator (* this , i) ;
1031
+ CurDir = It ;
1028
1032
1029
1033
// This file is a system header or C++ unfriendly if the dir is.
1030
1034
HeaderFileInfo &HFI = getFileInfo (&File->getFileEntry ());
@@ -1077,7 +1081,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
1077
1081
&File->getFileEntry (), isAngled, FoundByHeaderMap);
1078
1082
1079
1083
// Remember this location for the next lookup we do.
1080
- cacheLookupSuccess (CacheLookup, i , IncludeLoc);
1084
+ cacheLookupSuccess (CacheLookup, It , IncludeLoc);
1081
1085
return File;
1082
1086
}
1083
1087
@@ -1108,7 +1112,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
1108
1112
}
1109
1113
1110
1114
cacheLookupSuccess (LookupFileCache[Filename],
1111
- LookupFileCache[ScratchFilename].HitIdx , IncludeLoc);
1115
+ LookupFileCache[ScratchFilename].HitIt , IncludeLoc);
1112
1116
// FIXME: SuggestedModule.
1113
1117
return File;
1114
1118
}
@@ -1122,7 +1126,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
1122
1126
}
1123
1127
1124
1128
// Otherwise, didn't find it. Remember we didn't find this.
1125
- CacheLookup.HitIdx = SearchDirs. size ();
1129
+ CacheLookup.HitIt = search_dir_end ();
1126
1130
return None;
1127
1131
}
1128
1132
0 commit comments