[clang] [clang] Improve getFileIDLocal binary search. (PR #146510)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 1 08:17:52 PDT 2025
================
@@ -855,35 +857,24 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
break;
}
- NumProbes = 0;
- while (true) {
- unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
- SourceLocation::UIntTy MidOffset =
- getLocalSLocEntry(MiddleIndex).getOffset();
-
- ++NumProbes;
-
- // If the offset of the midpoint is too large, chop the high side of the
- // range to the midpoint.
- if (MidOffset > SLocOffset) {
- GreaterIndex = MiddleIndex;
- continue;
- }
+ while (LessIndex < GreaterIndex) {
----------------
hokein wrote:
I ran some experiments in the past, changing NumProbes from 8 to other values, but didn’t observe any performance improvements.
https://github.com/llvm/llvm-project/pull/146510
More information about the cfe-commits
mailing list