mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: use shared reloc slice in writelines method
Move to a shared/reused slice of loader.Reloc's in a couple of places in the linker's DWARF writelines method, as opposed to allocating a new slice each time. Small performance improvement. Change-Id: I06c64cf7ca00162d24d9421f1d6405c8808ebb83 Reviewed-on: https://go-review.googlesource.com/c/go/+/222758 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
efbab6dc7d
commit
69d9664f18
1 changed files with 3 additions and 2 deletions
|
|
@ -1213,11 +1213,12 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
|
|||
|
||||
// Grab files for inlined functions.
|
||||
// TODO: With difficulty, this could be moved into the compiler.
|
||||
rslice := []loader.Reloc{}
|
||||
for _, s := range unit.Textp2 {
|
||||
fnSym := loader.Sym(s)
|
||||
infosym, _, _, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
|
||||
drelocs := d.ldr.Relocs(infosym)
|
||||
rslice := drelocs.ReadSyms(nil)
|
||||
rslice = drelocs.ReadSyms(rslice)
|
||||
for ri := 0; ri < len(rslice); ri++ {
|
||||
r := &rslice[ri]
|
||||
if r.Type != objabi.R_DWARFFILEREF {
|
||||
|
|
@ -1307,7 +1308,7 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
|
|||
fnu := d.ldr.MakeSymbolUpdater(fnSym)
|
||||
|
||||
relocs := d.ldr.Relocs(fnSym)
|
||||
rslice := relocs.ReadAll(nil)
|
||||
rslice = relocs.ReadAll(rslice)
|
||||
|
||||
for ri := range rslice {
|
||||
r := &rslice[ri]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue