[clang-tools-extra] r364719 - [ADT] Implement llvm::bsearch() with std::partition_point()
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 30 02:18:00 PDT 2019
Author: maskray
Date: Sun Jun 30 02:17:59 2019
New Revision: 364719
URL: http://llvm.org/viewvc/llvm-project?rev=364719&view=rev
Log:
[ADT] Implement llvm::bsearch() with std::partition_point()
Summary:
Delete the begin-end form because the standard std::partition_point
can be easily used as a replacement.
The ranges-style llvm::bsearch will be renamed to llvm::partition_point
in the next clean-up patch.
The name "bsearch" doesn't meet people's expectation because in C:
> If two or more members compare equal, which member is returned is unspecified.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D63718
Modified:
clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
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=364719&r1=364718&r2=364719&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp Sun Jun 30 02:17:59 2019
@@ -50,8 +50,8 @@ public:
return;
advanceToChunk(ID);
// Try to find ID within current chunk.
- CurrentID = llvm::bsearch(CurrentID, DecompressedChunk.end(),
- [&](const DocID D) { return D >= ID; });
+ CurrentID = std::partition_point(CurrentID, DecompressedChunk.end(),
+ [&](const DocID D) { return D < ID; });
normalizeCursor();
}
@@ -103,8 +103,8 @@ private:
if ((CurrentChunk != Chunks.end() - 1) &&
((CurrentChunk + 1)->Head <= ID)) {
CurrentChunk =
- llvm::bsearch(CurrentChunk + 1, Chunks.end(),
- [&](const Chunk &C) { return C.Head >= ID; });
+ std::partition_point(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