Skip to content

Commit f257f56

Browse files
committed
Change loop condition in minRunLength (fixes #33)
For some reason the loop condition in minRunLength was MIN_MERGE=32 while the original CPython implementation uses 64 there. This commit changes that condition to 2*MIN_MERGE to bring the condition back to 64 at it should probably have been. Thanks @weeyizhi for identifying and the fix.
1 parent 298928c commit f257f56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/gfx/timsort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ template <typename RandomAccessIterator, typename Compare> class TimSort {
171171
GFX_TIMSORT_ASSERT(n >= 0);
172172

173173
diff_t r = 0;
174-
while (n >= MIN_MERGE) {
174+
while (n >= 2 * MIN_MERGE) {
175175
r |= (n & 1);
176176
n >>= 1;
177177
}

0 commit comments

Comments
 (0)