1
0
mirror of https://github.com/golang/go synced 2024-11-26 04:07:59 -07: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:
cui 2021-01-11 08:44:45 +00:00 committed by Emmanuel Odeke
parent 8336c311f8
commit 4bd4dfe96a

View File

@ -4,6 +4,10 @@
package ssa
import (
"math/bits"
)
// Code to compute lowest common ancestors in the dominator tree.
// https://en.wikipedia.org/wiki/Lowest_common_ancestor
// 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
var rangeMin [][]ID
rangeMin := make([][]ID, 0, bits.Len64(uint64(len(tour))))
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 {
r := make([]ID, len(tour)-s+1)