llvm.org GIT mirror llvm / 0b189e1
Fix mis-use of std::lower_bound Binary search in C++ is such a PITA. =/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308106 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 3 years ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
8787 // Make sure the offset is somewhere in our items array.
8888 if (Offset >= getLength())
8989 return make_error(stream_error_code::stream_too_short);
90 auto Iter = std::lower_bound(
91 ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset,
92 [](const uint32_t &A, const uint32_t &B) { return A <= B; });
90 ++Offset;
91 auto Iter =
92 std::lower_bound(ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset);
9393 size_t Idx = std::distance(ItemEndOffsets.begin(), Iter);
9494 assert(Idx < Items.size() && "binary search for offset failed");
9595 return Idx;