mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-23 03:39:42 +00:00
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
This commit is contained in:
parent
c09fbb030f
commit
0b189e17f8
@ -88,9 +88,9 @@ private:
|
||||
// Make sure the offset is somewhere in our items array.
|
||||
if (Offset >= getLength())
|
||||
return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
|
||||
auto Iter = std::lower_bound(
|
||||
ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset,
|
||||
[](const uint32_t &A, const uint32_t &B) { return A <= B; });
|
||||
++Offset;
|
||||
auto Iter =
|
||||
std::lower_bound(ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset);
|
||||
size_t Idx = std::distance(ItemEndOffsets.begin(), Iter);
|
||||
assert(Idx < Items.size() && "binary search for offset failed");
|
||||
return Idx;
|
||||
|
Loading…
Reference in New Issue
Block a user