aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/deadcode.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-04-19 14:02:21 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-04-21 12:02:20 +0000
commit7d56215bcbc5a2ef5e59805271b0ca6a4fd56e4d (patch)
tree6104b2e47ed48c24060d7222abc983678ecfc54b /src/cmd/link/internal/ld/deadcode.go
parent5a0881a1d1797a5f34c33ec4cf67cb97cc1aa634 (diff)
downloadgo-7d56215bcbc5a2ef5e59805271b0ca6a4fd56e4d.tar.xz
cmd/link: convert textp into a slice
Updates #15374 Change-Id: I3ea715735862fe9550b88d7a29def6cb9d4419a6 Reviewed-on: https://go-review.googlesource.com/22243 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
-rw-r--r--src/cmd/link/internal/ld/deadcode.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index c83a104a54..6a70ff581f 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -119,25 +119,13 @@ func deadcode(ctxt *Link) {
}
// Remove dead text but keep file information (z symbols).
- var last *LSym
- for s := ctxt.Textp; s != nil; s = s.Next {
- if !s.Attr.Reachable() {
- continue
+ textp := make([]*LSym, 0, len(ctxt.Textp))
+ for _, s := range ctxt.Textp {
+ if s.Attr.Reachable() {
+ textp = append(textp, s)
}
- if last == nil {
- ctxt.Textp = s
- } else {
- last.Next = s
- }
- last = s
- }
- if last == nil {
- ctxt.Textp = nil
- ctxt.Etextp = nil
- } else {
- last.Next = nil
- ctxt.Etextp = last
}
+ ctxt.Textp = textp
}
var markextra = []string{