mirror of
https://github.com/golang/go
synced 2024-11-25 05:47:57 -07:00
sort: avoid overflow in pivot calculation.
thanks to snilsson@nada.kth.se for the original CL. R=gri CC=golang-dev, snilsson https://golang.org/cl/3280044
This commit is contained in:
parent
0dc24603eb
commit
b389646243
@ -63,7 +63,7 @@ func swapRange(data Interface, a, b, n int) {
|
||||
}
|
||||
|
||||
func doPivot(data Interface, lo, hi int) (midlo, midhi int) {
|
||||
m := (lo + hi) / 2
|
||||
m := lo + (hi-lo)/2 // Written like this to avoid integer overflow.
|
||||
if hi-lo > 40 {
|
||||
// Tukey's ``Ninther,'' median of three medians of three.
|
||||
s := (hi - lo) / 8
|
||||
|
Loading…
Reference in New Issue
Block a user