[clangd] lower_bound -> bsearch, NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@358561 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/index/Symbol.cpp b/clangd/index/Symbol.cpp
index 5753571..cc4ce34 100644
--- a/clangd/index/Symbol.cpp
+++ b/clangd/index/Symbol.cpp
@@ -35,9 +35,8 @@
}
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();
diff --git a/clangd/index/dex/PostingList.cpp b/clangd/index/dex/PostingList.cpp
index 44a668b..67ed070 100644
--- a/clangd/index/dex/PostingList.cpp
+++ b/clangd/index/dex/PostingList.cpp
@@ -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 @@
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 @@
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();