[clang] [clang] SourceManager: Cache offsets for LastFileIDLookup to speed up getFileID (PR #146782)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 3 06:20:02 PDT 2025
================
@@ -832,13 +835,11 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
unsigned LessIndex = 0;
// upper bound of the search range.
unsigned GreaterIndex = LocalSLocEntryTable.size();
- if (LastFileIDLookup.ID >= 0) {
- // Use the LastFileIDLookup to prune the search space.
- if (LocalSLocEntryTable[LastFileIDLookup.ID].getOffset() < SLocOffset)
- LessIndex = LastFileIDLookup.ID;
- else
- GreaterIndex = LastFileIDLookup.ID;
- }
+ // Use the LastFileIDLookup to prune the search space.
+ if (LastLookupStartOffset < SLocOffset)
+ LessIndex = LastFileIDLookup.ID;
----------------
erichkeane wrote:
Oh! Does this mean that the old test here (`LastFileIDLookup.ID >= 0`) was a dead branch? Or actually, the alternative? Always executed?
Thats why i asked...
https://github.com/llvm/llvm-project/pull/146782
More information about the cfe-commits
mailing list