[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 7 10:43:27 PDT 2018


kbobyrev created this revision.
kbobyrev added reviewers: ioeric, sammccall, ilya-biryukov.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.

If the current element is already beyond advanceTo()'s DocID, just return instead of doing binary search. This simple optimization saves up to 3-4% performance,


https://reviews.llvm.org/D51802

Files:
  clang-tools-extra/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===================================================================
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -38,6 +38,8 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
     assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
+    if (peek() == ID)
+      return;
     Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51802.164460.patch
Type: text/x-patch
Size: 508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180907/df39c6a2/attachment.bin>


More information about the cfe-commits mailing list