]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj, cmd/link: random style cleanups
authorMatthew Dempsky <mdempsky@google.com>
Fri, 15 Apr 2016 02:44:55 +0000 (19:44 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Apr 2016 06:54:36 +0000 (06:54 +0000)
Identified during review of golang.org/cl/22103.

Change-Id: I86bab4cc17204df1e45deefdb0d0f9a8f6e17073
Reviewed-on: https://go-review.googlesource.com/22106
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/internal/obj/pcln.go
src/cmd/link/internal/ld/macho.go

index a086be9f66414ac5a10b4635be6f315811aeeca3..b1536eb224f806134365192096d75e0273f7ae39 100644 (file)
@@ -158,19 +158,18 @@ func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg
                return int32(pcln.Lastindex)
        }
 
-       var i int32
-       for i = 0; i < int32(len(pcln.File)); i++ {
-               file := pcln.File[i]
+       for i, file := range pcln.File {
                if file == f {
                        pcln.Lastfile = f
-                       pcln.Lastindex = int(i)
-                       return i
+                       pcln.Lastindex = i
+                       return int32(i)
                }
        }
+       i := len(pcln.File)
        pcln.File = append(pcln.File, f)
        pcln.Lastfile = f
-       pcln.Lastindex = int(i)
-       return i
+       pcln.Lastindex = i
+       return int32(i)
 }
 
 // pctospadj computes the sp adjustment in effect.
index 46cce4c331285c8ca6ce40208c097383e068ef68..e7d9fb5fe43d96bc0e2dd949e72fd2638fa98e96 100644 (file)
@@ -682,15 +682,11 @@ func machosymorder() {
 }
 
 func machosymtab() {
-       var s *LSym
-       var o *LSym
-       var p string
-
        symtab := Linklookup(Ctxt, ".machosymtab", 0)
        symstr := Linklookup(Ctxt, ".machosymstr", 0)
 
        for i := 0; i < nsortsym; i++ {
-               s = sortsym[i]
+               s := sortsym[i]
                Adduint32(Ctxt, symtab, uint32(symstr.Size))
 
                // Only add _ to C symbols. Go symbols have dot in the name.
@@ -699,20 +695,7 @@ func machosymtab() {
                }
 
                // replace "·" as ".", because DTrace cannot handle it.
-               if !strings.Contains(s.Extname, "·") {
-                       Addstring(symstr, s.Extname)
-               } else {
-                       for p = s.Extname; p != ""; p = p[1:] {
-                               if p[0] == 0xc2 && (p[1:])[0] == 0xb7 {
-                                       Adduint8(Ctxt, symstr, '.')
-                                       p = p[1:]
-                               } else {
-                                       Adduint8(Ctxt, symstr, p[0])
-                               }
-                       }
-
-                       Adduint8(Ctxt, symstr, '\x00')
-               }
+               Addstring(symstr, strings.Replace(s.Extname, "·", ".", -1))
 
                if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ {
                        Adduint8(Ctxt, symtab, 0x01)                // type N_EXT, external symbol
@@ -725,7 +708,7 @@ func machosymtab() {
                        } else {
                                Adduint8(Ctxt, symtab, 0x0e)
                        }
-                       o = s
+                       o := s
                        for o.Outer != nil {
                                o = o.Outer
                        }