From 011e40da85bddf83fee0ded83cb9115b7a88b3d4 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 26 Oct 2024 00:48:33 +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 e4250e12de..91ea7eb498 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -737,7 +737,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 ) @@ -1967,7 +1967,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 @@ -1990,7 +1990,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