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/internal/profile/profile.go | 2 +- src/internal/trace/traceviewer/mmu.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/internal') diff --git a/src/internal/profile/profile.go b/src/internal/profile/profile.go index afd1dd72ee..c8529d916d 100644 --- a/src/internal/profile/profile.go +++ b/src/internal/profile/profile.go @@ -507,7 +507,7 @@ type Demangler func(name []string) (map[string]string, error) // it will silently preserve the original names in case of any errors. func (p *Profile) Demangle(d Demangler) error { // Collect names to demangle. - var names []string + names := make([]string, 0, len(p.Function)) for _, fn := range p.Function { names = append(names, fn.SystemName) } diff --git a/src/internal/trace/traceviewer/mmu.go b/src/internal/trace/traceviewer/mmu.go index 190ce5afca..3de3b7fc2c 100644 --- a/src/internal/trace/traceviewer/mmu.go +++ b/src/internal/trace/traceviewer/mmu.go @@ -385,7 +385,7 @@ func (m *mmu) HandleDetails(w http.ResponseWriter, r *http.Request) { worst := mmuCurve.Examples(time.Duration(window), 10) // Construct a link for each window. - var links []linkedUtilWindow + links := make([]linkedUtilWindow, 0, len(worst)) for _, ui := range worst { links = append(links, m.newLinkedUtilWindow(ui, time.Duration(window))) } -- cgit v1.3