node-timsort
node-timsort copied to clipboard
Prevent integer overflow during midpoint calculation in `binaryInsertionSort`
Changed line 211 from
let mid = (left + right) >>> 1;
to
let mid = left + ((right - left) >>> 1);
because the previous implementation would yield incorrect results for large values of left and/or right.
This is the way the operation is done, for example, in gallopLeft on line 315