]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: use shared reloc slice in writelines method
authorThan McIntosh <thanm@google.com>
Tue, 10 Mar 2020 14:08:50 +0000 (10:08 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 10 Mar 2020 17:19:08 +0000 (17:19 +0000)
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>
src/cmd/link/internal/ld/dwarf.go

index b94e55fc2e117433d6b3a60f5f077d2168e7e96a..5e89b3897e59bdf0188cfc015aced33eda0890e1 100644 (file)
@@ -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]