1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:54:39 -07:00

[dev.link] cmd/link: minor perf tweak for PropagateLoaderChangesToSymbols

When fixing up relocations in PropagateLoaderChangesToSymbols, don't
reallocate the target sym.Symbol relocation slice if it already has
the desired size (this gets rid of some unneeded allocations).

Change-Id: I05287772c18cab861c2df805fa9497103fb00dcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/224420
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Than McIntosh 2020-03-20 10:34:58 -04:00
parent 0dff5b0b9e
commit 7055f01e12

View File

@ -1977,7 +1977,9 @@ func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, syms *sym.Symb
s := l.Syms[cand]
relocs := l.Relocs(cand)
rslice = relocs.ReadAll(rslice)
s.R = make([]sym.Reloc, len(rslice))
if len(s.R) != len(rslice) {
s.R = make([]sym.Reloc, len(rslice))
}
l.convertRelocations(rslice, s, true)
}