mirror of
https://github.com/golang/go
synced 2024-11-06 04:16:11 -07:00
[dev.link] cmd/link: further reduce unnecessary field reading
Following CL 218479, there are more places where we don't need to read all the fields. Change-Id: I70889cd3f0514ef2c542317f3fe24f5ef99b41d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/220057 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
25f1b093fe
commit
c4ccd08a25
@ -86,7 +86,7 @@ func (d *deadcodePass2) init() {
|
||||
// but we do keep the symbols it refers to.
|
||||
exportsIdx := d.ldr.Lookup("go.plugin.exports", 0)
|
||||
if exportsIdx != 0 {
|
||||
d.ReadRelocs(exportsIdx)
|
||||
d.ReadRelocSyms(exportsIdx)
|
||||
for i := 0; i < len(d.rtmp); i++ {
|
||||
d.mark(d.rtmp[i].Sym, 0)
|
||||
}
|
||||
@ -227,7 +227,7 @@ func (d *deadcodePass2) mark(symIdx, parent loader.Sym) {
|
||||
}
|
||||
|
||||
func (d *deadcodePass2) markMethod(m methodref2) {
|
||||
d.ReadRelocs(m.src)
|
||||
d.ReadRelocSyms(m.src)
|
||||
d.mark(d.rtmp[m.r].Sym, m.src)
|
||||
d.mark(d.rtmp[m.r+1].Sym, m.src)
|
||||
d.mark(d.rtmp[m.r+2].Sym, m.src)
|
||||
@ -410,3 +410,9 @@ func (d *deadcodePass2) ReadRelocs(symIdx loader.Sym) {
|
||||
relocs := d.ldr.Relocs(symIdx)
|
||||
d.rtmp = relocs.ReadAll(d.rtmp)
|
||||
}
|
||||
|
||||
// Like ReadRelocs, but only reads target symbols.
|
||||
func (d *deadcodePass2) ReadRelocSyms(symIdx loader.Sym) {
|
||||
relocs := d.ldr.Relocs(symIdx)
|
||||
d.rtmp = relocs.ReadSyms(d.rtmp)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user