@@ -1755,28 +1755,24 @@ struct s_MergeState {
17551755
17561756#define _binarysort_BISECT (L , R ) \
17571757 do { \
1758- do { \
1759- M = (L + R) >> 1; \
1760- IFLT(pivot, a[M]) \
1761- R = M; \
1762- else \
1763- L = M + 1; \
1764- } while (L < R); \
1765- assert(L == R); \
1766- } while (0)
1767-
1768- #define _binarysort_INSORT (idx , tmp ) \
1769- do { \
1770- for (tmp = ok; tmp > idx; --tmp) \
1771- a[tmp] = a[tmp - 1]; \
1772- a[idx] = pivot; \
1773- if (has_values) { \
1774- pivot = v[ok]; \
1775- for (tmp = ok; tmp > idx; --tmp) \
1776- v[tmp] = v[tmp - 1]; \
1777- v[idx] = pivot; \
1778- } \
1779- } while (0)
1758+ M = (L + R) >> 1; \
1759+ IFLT(pivot, a[M]) \
1760+ R = M; \
1761+ else \
1762+ L = M + 1; \
1763+ } while (L < R); \
1764+ assert(L == R);
1765+
1766+ #define _binarysort_INSORT (idx , tmp ) \
1767+ for (tmp = ok; tmp > idx; --tmp) \
1768+ a[tmp] = a[tmp - 1]; \
1769+ a[idx] = pivot; \
1770+ if (has_values) { \
1771+ pivot = v[ok]; \
1772+ for (tmp = ok; tmp > idx; --tmp) \
1773+ v[tmp] = v[tmp - 1]; \
1774+ v[idx] = pivot; \
1775+ }
17801776
17811777/* binarysort is the best method for sorting small arrays: it does few
17821778 compares, but can do data movement quadratic in the number of elements.
@@ -1813,8 +1809,8 @@ binarysort(MergeState *ms, const sortslice *ss, Py_ssize_t n, Py_ssize_t ok)
18131809 pivot = a [ok ];
18141810
18151811 assert (aL < aR );
1816- _binarysort_BISECT (aL , aR );
1817- _binarysort_INSORT (aL , M );
1812+ _binarysort_BISECT (aL , aR )
1813+ _binarysort_INSORT (aL , M )
18181814 ++ ok ;
18191815
18201816 Py_ssize_t m = ok < 5 ? 11 : ok + 6 ;
@@ -1828,10 +1824,10 @@ binarysort(MergeState *ms, const sortslice *ss, Py_ssize_t n, Py_ssize_t ok)
18281824 pivot = a [ok ];
18291825
18301826 assert (aL < aR );
1831- _binarysort_BISECT (aL , aR );
1832- _binarysort_INSORT (aL , M );
1827+ _binarysort_BISECT (aL , aR )
1828+ _binarysort_INSORT (aL , M )
18331829
1834- std += mu < aL ? aL - mu : mu - aL ;
1830+ std += labs ( aL - mu ) ;
18351831 std /= 2 ; // EWMA with alpha=0.5
18361832 mu = aL ;
18371833 }
@@ -1898,9 +1894,9 @@ binarysort(MergeState *ms, const sortslice *ss, Py_ssize_t n, Py_ssize_t ok)
18981894 aL = M + 1 ;
18991895 }
19001896 assert (aL == aR );
1901- _binarysort_INSORT (aL , M );
1897+ _binarysort_INSORT (aL , M )
19021898
1903- std += mu < aL ? aL - mu : mu - aL ;
1899+ std += labs ( aL - mu ) ;
19041900 std /= 2 ; // EWMA with alpha=0.5
19051901 mu = aL ;
19061902 std_max += !(ok % 4 );
0 commit comments