From 8096b47dd09fcda8712f7a3c07dced5244123a4d Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 2 May 2023 01:06:11 +0700 Subject: all: prealloc slice with possible minimum capabilities --- src/cmd/dist/build.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cmd/dist') diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 96199bcbfa..f778c85475 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -707,7 +707,7 @@ func runInstall(pkg string, ch chan struct{}) { // Start final link command line. // Note: code below knows that link.p[targ] is the target. var ( - link []string + link = make([]string, 0, 1) targ int ispackcmd bool ) @@ -1914,7 +1914,7 @@ func cmdlist() { brokenFlag := flag.Bool("broken", false, "include broken ports") xflagparse(0) - var plats []string + plats := make([]string, 0, len(cgoEnabled)) for p := range cgoEnabled { if broken[p] && !*brokenFlag { continue @@ -1937,7 +1937,7 @@ func cmdlist() { FirstClass bool Broken bool `json:",omitempty"` } - var results []jsonResult + results := make([]jsonResult, 0, len(plats)) for _, p := range plats { fields := strings.Split(p, "/") results = append(results, jsonResult{ -- cgit v1.3