[haiku-commits] haiku: hrev52116 - src/apps/haikudepot

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 18 Jul 2018 19:05:45 -0400 (EDT)

hrev52116 adds 1 changeset to branch 'master'
old head: 4aff6a8a2b90c4bfd6ed1d3fa3948df107adabe5
new head: b3a7d91b2ec9fba521320b7e1d0c9a7919b30608
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b3a7d91b2ec9+%5E4aff6a8a2b90

----------------------------------------------------------------------------

b3a7d91b2ec9: HaikuDepot : Fix for List Algorithm
  
  Fix a mistake in the binary search and insert
  algorithms that was causing stability issues.
  
  Fixes #14284

                                    [ Andrew Lindesay <apl@xxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev52116
Commit:      b3a7d91b2ec9fba521320b7e1d0c9a7919b30608
URL:         https://git.haiku-os.org/haiku/commit/?id=b3a7d91b2ec9
Author:      Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:        Wed Jul 18 21:05:58 2018 UTC

Ticket:      https://dev.haiku-os.org/ticket/14284

----------------------------------------------------------------------------

1 file changed, 2 insertions(+), 2 deletions(-)
src/apps/haikudepot/List.h | 4 ++--

----------------------------------------------------------------------------

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);


Other related posts:

  • » [haiku-commits] haiku: hrev52116 - src/apps/haikudepot - waddlesplash