cmd/link: make Allsym a slice

Looks a tiny bit faster, which is a surprise. Probably noise.
Motivation is making the LSym structure a little easier to understand.

Linking juju, best of 10:

before: real 0m4.811s user 0m5.582s
after:  real 0m4.611s user 0m5.267s

Change-Id: Idbedaf4a6e6e199036a1bbb6760e98c94ed2c282
Reviewed-on: https://go-review.googlesource.com/20142
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
David Crawshaw 2016-03-02 15:59:38 -05:00
parent 4598382724
commit 4b92cd4ec1
10 changed files with 29 additions and 39 deletions

View file

@ -599,7 +599,7 @@ func loadlib() {
if Linkmode == LinkInternal {
// Drop all the cgo_import_static declarations.
// Turns out we won't be needing them.
for s := Ctxt.Allsym; s != nil; s = s.Allsym {
for _, s := range Ctxt.Allsym {
if s.Type == obj.SHOSTOBJ {
// If a symbol was marked both
// cgo_import_static and cgo_import_dynamic,
@ -679,7 +679,7 @@ func loadlib() {
// If we have any undefined symbols in external
// objects, try to read them from the libgcc file.
any := false
for s := Ctxt.Allsym; s != nil; s = s.Allsym {
for _, s := range Ctxt.Allsym {
for _, r := range s.R {
if r.Sym != nil && r.Sym.Type&obj.SMASK == obj.SXREF && r.Sym.Name != ".got" {
any = true
@ -1904,7 +1904,7 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
put(s, s.Name, 'T', s.Value, s.Size, int(s.Version), nil)
}
for s := Ctxt.Allsym; s != nil; s = s.Allsym {
for _, s := range Ctxt.Allsym {
if s.Hidden || ((s.Name == "" || s.Name[0] == '.') && s.Version == 0 && s.Name != ".rathole" && s.Name != ".TOC.") {
continue
}