Skip to content

Commit

Permalink
internal/gosym: preallocate inlined call slice
Browse files Browse the repository at this point in the history
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 <quimmuntal@gmail.com>
Reviewed-by: Joedian Reid <joedian@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
  • Loading branch information
qmuntal authored and gopherbot committed Apr 23, 2024
1 parent 230480c commit 63adf47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/gosym/additions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 63adf47

Please sign in to comment.