mirror of
https://github.com/golang/go
synced 2024-11-18 15:44:41 -07:00
sort: deduplicate inner loop of Stable
benchmark old ns/op new ns/op delta BenchmarkStableInt1K 117212 116287 -0.79% BenchmarkStableInt64K 9632002 9587872 -0.46% BenchmarkStable1e4 40044309 39865644 -0.45% BenchmarkStable1e2 126985 126456 -0.42% BenchmarkStableString1K 389774 391052 +0.33% BenchmarkStable1e6 8183202516 8157693442 -0.31% Change-Id: I14e518ad49ecce3d1fc2b056e1acd5e5a2de8144 Reviewed-on: https://go-review.googlesource.com/1821 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
ddb24da850
commit
6ceb60444d
@ -359,30 +359,25 @@ func symMerge(data Interface, a, m, b int) {
|
||||
|
||||
mid := a + (b-a)/2
|
||||
n := mid + m
|
||||
start := 0
|
||||
var start, r int
|
||||
if m > mid {
|
||||
start = n - b
|
||||
r, p := mid, n-1
|
||||
for start < r {
|
||||
c := start + (r-start)/2
|
||||
if !data.Less(p-c, c) {
|
||||
start = c + 1
|
||||
} else {
|
||||
r = c
|
||||
}
|
||||
}
|
||||
r = mid
|
||||
} else {
|
||||
start = a
|
||||
r, p := m, n-1
|
||||
for start < r {
|
||||
c := start + (r-start)/2
|
||||
if !data.Less(p-c, c) {
|
||||
start = c + 1
|
||||
} else {
|
||||
r = c
|
||||
}
|
||||
r = m
|
||||
}
|
||||
p := n - 1
|
||||
|
||||
for start < r {
|
||||
c := start + (r-start)/2
|
||||
if !data.Less(p-c, c) {
|
||||
start = c + 1
|
||||
} else {
|
||||
r = c
|
||||
}
|
||||
}
|
||||
|
||||
end := n - start
|
||||
rotate(data, start, m, end)
|
||||
symMerge(data, a, start, mid)
|
||||
|
Loading…
Reference in New Issue
Block a user