|
9 | 9 | #include "PostingList.h"
|
10 | 10 | #include "Iterator.h"
|
11 | 11 | #include "Token.h"
|
| 12 | +#include "llvm/ADT/STLExtras.h" |
12 | 13 | #include "llvm/Support/Error.h"
|
13 | 14 | #include "llvm/Support/MathExtras.h"
|
14 | 15 |
|
@@ -49,7 +50,8 @@ class ChunkIterator : public Iterator {
|
49 | 50 | return;
|
50 | 51 | advanceToChunk(ID);
|
51 | 52 | // Try to find ID within current chunk.
|
52 |
| - CurrentID = std::lower_bound(CurrentID, std::end(DecompressedChunk), ID); |
| 53 | + CurrentID = llvm::bsearch(CurrentID, DecompressedChunk.end(), |
| 54 | + [&](const DocID D) { return D >= ID; }); |
53 | 55 | normalizeCursor();
|
54 | 56 | }
|
55 | 57 |
|
@@ -100,10 +102,9 @@ class ChunkIterator : public Iterator {
|
100 | 102 | void advanceToChunk(DocID ID) {
|
101 | 103 | if ((CurrentChunk != Chunks.end() - 1) &&
|
102 | 104 | ((CurrentChunk + 1)->Head <= ID)) {
|
103 |
| - // Find the next chunk with Head >= ID. |
104 |
| - CurrentChunk = std::lower_bound( |
105 |
| - CurrentChunk + 1, Chunks.end(), ID, |
106 |
| - [](const Chunk &C, const DocID ID) { return C.Head <= ID; }); |
| 105 | + CurrentChunk = |
| 106 | + llvm::bsearch(CurrentChunk + 1, Chunks.end(), |
| 107 | + [&](const Chunk &C) { return C.Head >= ID; }); |
107 | 108 | --CurrentChunk;
|
108 | 109 | DecompressedChunk = CurrentChunk->decompress();
|
109 | 110 | CurrentID = DecompressedChunk.begin();
|
|
0 commit comments