[PATCH] D82497: [Clang][SourceManager] optimize getFileIDLocal()

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 10:15:23 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG408efffbe4a5: [Clang][SourceManager] optimize getFileIDLocal() (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82497/new/

https://reviews.llvm.org/D82497

Files:
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===================================================================
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -898,9 +898,8 @@
     }
 
     // If the middle index contains the value, succeed and return.
-    // FIXME: This could be made faster by using a function that's aware of
-    // being in the local area.
-    if (isOffsetInFileID(FileID::get(MiddleIndex), SLocOffset)) {
+    if (MiddleIndex + 1 == LocalSLocEntryTable.size() ||
+        SLocOffset < getLocalSLocEntry(MiddleIndex + 1).getOffset()) {
       FileID Res = FileID::get(MiddleIndex);
 
       // If this isn't a macro expansion, remember it.  We have good locality


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82497.273434.patch
Type: text/x-patch
Size: 716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200625/2e70d01a/attachment-0001.bin>


More information about the cfe-commits mailing list