]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: replace unrolled Cput loops with Cwrite/Cwritestring
authorMatthew Dempsky <mdempsky@google.com>
Fri, 15 Sep 2017 18:38:24 +0000 (11:38 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Sep 2017 19:09:39 +0000 (19:09 +0000)
Passes toolstash-check -all.

Change-Id: I1c85a2c0390517f4e9cdbddddbf3c353edca65b3
Reviewed-on: https://go-review.googlesource.com/64051
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/symtab.go
src/cmd/link/internal/mips64/asm.go
src/cmd/link/internal/ppc64/asm.go
src/cmd/link/internal/x86/asm.go

index 20ef5956a983f9258727c8c14ff772deb319e024..0660a6d3bfcc5a1e755657620661a45d0899c510 100644 (file)
@@ -781,10 +781,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }
 
index c27672da7d2a1fcc5eeda3363bcc49a00a951b4b..2c959b0e96ef64139904ada74701da60870c24a5 100644 (file)
@@ -829,10 +829,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }
 
index bb0bf267f0327defedec3d7a5eba7b3268c96492..5955f2cd6ba1684cb72ae8b0579158118495b060 100644 (file)
@@ -465,10 +465,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }
 
index cd364f05765f2a5ffa42dfe3a658fccd2864851f..0edf76ec5a85c5b9d85a404bdb5c8308b02b08c5 100644 (file)
@@ -1120,9 +1120,7 @@ func getElfEhdr() *ElfEhdr {
 }
 
 func elf64writehdr() uint32 {
-       for i := 0; i < EI_NIDENT; i++ {
-               Cput(ehdr.ident[i])
-       }
+       Cwrite(ehdr.ident[:])
        Thearch.Wput(ehdr.type_)
        Thearch.Wput(ehdr.machine)
        Thearch.Lput(ehdr.version)
@@ -1140,9 +1138,7 @@ func elf64writehdr() uint32 {
 }
 
 func elf32writehdr() uint32 {
-       for i := 0; i < EI_NIDENT; i++ {
-               Cput(ehdr.ident[i])
-       }
+       Cwrite(ehdr.ident[:])
        Thearch.Wput(ehdr.type_)
        Thearch.Wput(ehdr.machine)
        Thearch.Lput(ehdr.version)
index ca97cb23cf8bfc117cb7aa2b3bb2b1c99127e996..9812fe60531b8777e14707ff10375493fcf5ba8d 100644 (file)
@@ -233,13 +233,10 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, go
                Lputb(uint32(addr))
                Cput(uint8(t + 0x80)) /* 0x80 is variable length */
 
-               var i int
-               for i = 0; i < len(s); i++ {
-                       Cput(s[i])
-               }
+               Cwritestring(s)
                Cput(0)
 
-               Symsize += int32(l) + 1 + int32(i) + 1
+               Symsize += int32(l) + 1 + int32(len(s)) + 1
 
        default:
                return
index d1baef612fad6d6ec0043fb76b20fe17583fc2ee..c3100331e803ce422e04162e563c585009f12547 100644 (file)
@@ -258,10 +258,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }
                }
index 2f0947aff8de82d1a896584c4f472fbdbeb9480b..4bec2172df0b225503a86cf5a24c2e3d0d1108fa 100644 (file)
@@ -987,10 +987,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }
                }
index 069ee4702e8a6292db1b14d8e69a3eceb3eb2f67..bfdee795a4a650c2807afb088553822bc18760c9 100644 (file)
@@ -709,10 +709,7 @@ func asmb(ctxt *ld.Link) {
                        sym := ctxt.Syms.Lookup("pclntab", 0)
                        if sym != nil {
                                ld.Lcsize = int32(len(sym.P))
-                               for i := 0; int32(i) < ld.Lcsize; i++ {
-                                       ld.Cput(sym.P[i])
-                               }
-
+                               ld.Cwrite(sym.P)
                                ld.Cflush()
                        }