From 63adf478672df31518e0b86dce5b8fd1cc7811ae Mon Sep 17 00:00:00 2001 From: qmuntal Date: Tue, 23 Apr 2024 16:46:09 +0200 Subject: [PATCH] internal/gosym: preallocate inlined call slice LineTable.InlineTree allocates a slice whose length is known in advance. Preallocate it to avoid reallocations. Change-Id: I1939f6d4e956ccb5d2b68e10695622784d8ced38 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/581135 Run-TryBot: Quim Muntal Reviewed-by: Joedian Reid TryBot-Result: Gopher Robot Auto-Submit: Quim Muntal LUCI-TryBot-Result: Go LUCI Reviewed-by: Zvonimir Pavlinovic --- internal/gosym/additions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/gosym/additions.go b/internal/gosym/additions.go index 4c41f558..022cf92e 100644 --- a/internal/gosym/additions.go +++ b/internal/gosym/additions.go @@ -60,7 +60,7 @@ func (t *LineTable) InlineTree(f *Func, goFuncValue, baseAddr uint64, progReader } r := io.NewSectionReader(progReader, offset, 1<<32) // pick a size larger than we need - var ics []InlinedCall + ics := make([]InlinedCall, 0, f.inlineTreeCount) for i := 0; i < f.inlineTreeCount; i++ { if t.version >= ver120 { var ric rawInlinedCall120