Skip to content

Commit a135ec8

Browse files
committed
replace labs with ternary
1 parent 181fef4 commit a135ec8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Objects/listobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ binarysort(MergeState *ms, const sortslice *ss, Py_ssize_t n, Py_ssize_t ok)
18311831
_binarysort_BISECT(aL, aR);
18321832
_binarysort_INSORT(aL, M);
18331833

1834-
std += labs(aL - mu);
1834+
std += mu < aL ? aL - mu : mu - aL;
18351835
std /= 2; // EWMA with alpha=0.5
18361836
mu = aL;
18371837
}
@@ -1900,7 +1900,7 @@ binarysort(MergeState *ms, const sortslice *ss, Py_ssize_t n, Py_ssize_t ok)
19001900
assert(aL == aR);
19011901
_binarysort_INSORT(aL, M);
19021902

1903-
std += labs(aL - mu);
1903+
std += mu < aL ? aL - mu : mu - aL;
19041904
std /= 2; // EWMA with alpha=0.5
19051905
std_max += !(ok % 4);
19061906
mu = aL;

0 commit comments

Comments
 (0)