[clang-tools-extra] r358561 - [clangd] lower_bound -> bsearch, NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 17 00:00:36 PDT 2019
Author: sammccall
Date: Wed Apr 17 00:00:36 2019
New Revision: 358561
URL: http://llvm.org/viewvc/llvm-project?rev=358561&view=rev
Log:
[clangd] lower_bound -> bsearch, NFC
Modified:
clang-tools-extra/trunk/clangd/index/Symbol.cpp
clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
Modified: clang-tools-extra/trunk/clangd/index/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Symbol.cpp?rev=358561&r1=358560&r2=358561&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Symbol.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Symbol.cpp Wed Apr 17 00:00:36 2019
@@ -35,9 +35,8 @@ float quality(const Symbol &S) {
}
SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
- auto It = std::lower_bound(
- Symbols.begin(), Symbols.end(), ID,
- [](const Symbol &S, const SymbolID &I) { return S.ID < I; });
+ auto It =
+ llvm::bsearch(Symbols, [&](const Symbol &S) { return !(S.ID < ID); });
if (It != Symbols.end() && It->ID == ID)
return It;
return Symbols.end();
Modified: clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp?rev=358561&r1=358560&r2=358561&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp Wed Apr 17 00:00:36 2019
@@ -9,6 +9,7 @@
#include "PostingList.h"
#include "Iterator.h"
#include "Token.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h"
@@ -49,7 +50,8 @@ public:
return;
advanceToChunk(ID);
// Try to find ID within current chunk.
- CurrentID = std::lower_bound(CurrentID, std::end(DecompressedChunk), ID);
+ CurrentID = llvm::bsearch(CurrentID, DecompressedChunk.end(),
+ [&](const DocID D) { return D >= ID; });
normalizeCursor();
}
@@ -100,10 +102,9 @@ private:
void advanceToChunk(DocID ID) {
if ((CurrentChunk != Chunks.end() - 1) &&
((CurrentChunk + 1)->Head <= ID)) {
- // Find the next chunk with Head >= ID.
- CurrentChunk = std::lower_bound(
- CurrentChunk + 1, Chunks.end(), ID,
- [](const Chunk &C, const DocID ID) { return C.Head <= ID; });
+ CurrentChunk =
+ llvm::bsearch(CurrentChunk + 1, Chunks.end(),
+ [&](const Chunk &C) { return C.Head >= ID; });
--CurrentChunk;
DecompressedChunk = CurrentChunk->decompress();
CurrentID = DecompressedChunk.begin();
More information about the cfe-commits
mailing list