diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-04-17 07:00:36 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-04-17 07:00:36 +0000 |
| commit | 277754c71da76ba00c426c122d58d95fadcb353d (patch) | |
| tree | 07388d4caef5aff4718d9015c0b8b61797a53149 | |
| parent | 00806458469829bc0d3bfd59b9ae9925c570b2ff (diff) | |
| download | bcm5719-llvm-277754c71da76ba00c426c122d58d95fadcb353d.tar.gz bcm5719-llvm-277754c71da76ba00c426c122d58d95fadcb353d.zip | |
[clangd] lower_bound -> bsearch, NFC
llvm-svn: 358561
| -rw-r--r-- | clang-tools-extra/clangd/index/Symbol.cpp | 5 | ||||
| -rw-r--r-- | clang-tools-extra/clangd/index/dex/PostingList.cpp | 11 |
2 files changed, 8 insertions, 8 deletions
diff --git a/clang-tools-extra/clangd/index/Symbol.cpp b/clang-tools-extra/clangd/index/Symbol.cpp index 5753571676f..cc4ce3468ee 100644 --- a/clang-tools-extra/clangd/index/Symbol.cpp +++ b/clang-tools-extra/clangd/index/Symbol.cpp @@ -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(); diff --git a/clang-tools-extra/clangd/index/dex/PostingList.cpp b/clang-tools-extra/clangd/index/dex/PostingList.cpp index 44a668bb617..67ed070a66a 100644 --- a/clang-tools-extra/clangd/index/dex/PostingList.cpp +++ b/clang-tools-extra/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 @@ 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(); |

