mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/ssa: prealloc slice
Change-Id: I9943a4f931c251a69bc8244c0d7723a0a3552073
GitHub-Last-Rev: d9dd94ae44
GitHub-Pull-Request: golang/go#43622
Reviewed-on: https://go-review.googlesource.com/c/go/+/282992
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
8336c311f8
commit
4bd4dfe96a
1 changed files with 5 additions and 1 deletions
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
// Code to compute lowest common ancestors in the dominator tree.
|
// Code to compute lowest common ancestors in the dominator tree.
|
||||||
// https://en.wikipedia.org/wiki/Lowest_common_ancestor
|
// https://en.wikipedia.org/wiki/Lowest_common_ancestor
|
||||||
// https://en.wikipedia.org/wiki/Range_minimum_query#Solution_using_constant_time_and_linearithmic_space
|
// https://en.wikipedia.org/wiki/Range_minimum_query#Solution_using_constant_time_and_linearithmic_space
|
||||||
|
|
@ -79,7 +83,7 @@ func makeLCArange(f *Func) *lcaRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute fast range-minimum query data structure
|
// Compute fast range-minimum query data structure
|
||||||
var rangeMin [][]ID
|
rangeMin := make([][]ID, 0, bits.Len64(uint64(len(tour))))
|
||||||
rangeMin = append(rangeMin, tour) // 1-size windows are just the tour itself.
|
rangeMin = append(rangeMin, tour) // 1-size windows are just the tour itself.
|
||||||
for logS, s := 1, 2; s < len(tour); logS, s = logS+1, s*2 {
|
for logS, s := 1, 2; s < len(tour); logS, s = logS+1, s*2 {
|
||||||
r := make([]ID, len(tour)-s+1)
|
r := make([]ID, len(tour)-s+1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue