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

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 10 00:58:50 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL341781: [clangd] Make advanceTo() faster on Posting Lists (authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51802?vs=164623&id=164625#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51802

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


Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
@@ -38,7 +38,10 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
     assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-    Index = std::lower_bound(Index, std::end(Documents), ID);
+    // If current ID is beyond requested one, iterator is already in the right
+    // state.
+    if (peek() < ID)
+      Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51802.164625.patch
Type: text/x-patch
Size: 704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180910/8703e6e0/attachment.bin>


More information about the cfe-commits mailing list