From b3a7d91b2ec9fba521320b7e1d0c9a7919b30608 Mon Sep 17 00:00:00 2001 From: Andrew Lindesay Date: Wed, 18 Jul 2018 23:05:58 +0200 Subject: [PATCH] HaikuDepot : Fix for List Algorithm Fix a mistake in the binary search and insert algorithms that was causing stability issues. Fixes #14284 --- src/apps/haikudepot/List.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/haikudepot/List.h b/src/apps/haikudepot/List.h index 42f6c2f404..186801875f 100644 --- a/src/apps/haikudepot/List.h +++ b/src/apps/haikudepot/List.h @@ -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);