From d9dd94ae4444cb0106756cdb98c1c5fa12fa5f79 Mon Sep 17 00:00:00 2001 From: cui Date: Mon, 11 Jan 2021 16:34:10 +0800 Subject: [PATCH] cmd/compile/internal/ssa: prealloc slice Change-Id: Iff222f4cd1be982a9d7609d8d5259e5c4d087fe0 --- src/cmd/compile/internal/ssa/lca.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ssa/lca.go b/src/cmd/compile/internal/ssa/lca.go index 5cb73911df..90daebe44f 100644 --- a/src/cmd/compile/internal/ssa/lca.go +++ b/src/cmd/compile/internal/ssa/lca.go @@ -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)