mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
1 changed files with 13 additions and 18 deletions
|
|
@ -359,30 +359,25 @@ func symMerge(data Interface, a, m, b int) {
|
||||||
|
|
||||||
mid := a + (b-a)/2
|
mid := a + (b-a)/2
|
||||||
n := mid + m
|
n := mid + m
|
||||||
start := 0
|
var start, r int
|
||||||
if m > mid {
|
if m > mid {
|
||||||
start = n - b
|
start = n - b
|
||||||
r, p := mid, n-1
|
r = mid
|
||||||
for start < r {
|
|
||||||
c := start + (r-start)/2
|
|
||||||
if !data.Less(p-c, c) {
|
|
||||||
start = c + 1
|
|
||||||
} else {
|
|
||||||
r = c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
start = a
|
start = a
|
||||||
r, p := m, n-1
|
r = m
|
||||||
for start < r {
|
}
|
||||||
c := start + (r-start)/2
|
p := n - 1
|
||||||
if !data.Less(p-c, c) {
|
|
||||||
start = c + 1
|
for start < r {
|
||||||
} else {
|
c := start + (r-start)/2
|
||||||
r = c
|
if !data.Less(p-c, c) {
|
||||||
}
|
start = c + 1
|
||||||
|
} else {
|
||||||
|
r = c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end := n - start
|
end := n - start
|
||||||
rotate(data, start, m, end)
|
rotate(data, start, m, end)
|
||||||
symMerge(data, a, start, mid)
|
symMerge(data, a, start, mid)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue