HaikuDepot : Fix for List Algorithm

Fix a mistake in the binary search and insert
algorithms that was causing stability issues.

Fixes #14284
This commit is contained in:
Andrew Lindesay 2018-07-18 23:05:58 +02:00
parent 4aff6a8a2b
commit b3a7d91b2e
1 changed files with 2 additions and 2 deletions

View File

@ -278,7 +278,7 @@ private:
if (end - start < BINARY_SEARCH_LINEAR_THRESHOLD)
return _BinarySearchLinearBounded(context, compareFunc, start, end);
int32 mid = start + (end - start);
int32 mid = start + ((end - start) >> 1);
if (compareFunc(context, ItemAtFast(mid)) >= 0)
return _BinarySearchBounded(context, compareFunc, mid, end);
@ -315,7 +315,7 @@ private:
if(end - start < BINARY_SEARCH_LINEAR_THRESHOLD)
return _AddOrderedLinearBounded(copyFrom, compareFunc, start, end);
int32 mid = start + (end - start);
int32 mid = start + ((end - start) >> 1);
if (compareFunc(copyFrom, ItemAtFast(mid)) >= 0)
return _AddOrderedBounded(copyFrom, compareFunc, mid, end);