From 494e317fbf47eac5edfc0664506d5e1f1f3eafed Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 3 Mar 2015 22:20:16 -0500 Subject: [PATCH] cmd/internal: rewrite fmt.Sprintf("%s", x) to x Change-Id: I764933f4928bb9d0d119fbfe44a193ce1449b61e Reviewed-on: https://go-review.googlesource.com/6791 Reviewed-by: Brad Fitzpatrick Reviewed-by: Rob Pike --- src/cmd/internal/ld/go.go | 12 ++++++------ src/cmd/internal/obj/i386/list8.go | 2 +- src/cmd/internal/obj/obj.go | 6 +++--- src/cmd/internal/obj/x86/list6.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cmd/internal/ld/go.go b/src/cmd/internal/ld/go.go index 718379253df..1ad3bff8662 100644 --- a/src/cmd/internal/ld/go.go +++ b/src/cmd/internal/ld/go.go @@ -694,19 +694,19 @@ func deadcode() { } // record field tracking references - fmt_ := "" - + var buf bytes.Buffer var p *LSym for s := Ctxt.Allsym; s != nil; s = s.Allsym { if strings.HasPrefix(s.Name, "go.track.") { s.Special = 1 // do not lay out in data segment s.Hide = 1 if s.Reachable { - fmt_ += fmt.Sprintf("%s", s.Name[9:]) + buf.WriteString(s.Name[9:]) for p = s.Reachparent; p != nil; p = p.Reachparent { - fmt_ += fmt.Sprintf("\t%s", p.Name) + buf.WriteString("\t") + buf.WriteString(p.Name) } - fmt_ += fmt.Sprintf("\n") + buf.WriteString("\n") } s.Type = SCONST @@ -721,7 +721,7 @@ func deadcode() { if !s.Reachable { return } - addstrdata(tracksym, fmt_) + addstrdata(tracksym, buf.String()) } func doweak() { diff --git a/src/cmd/internal/obj/i386/list8.go b/src/cmd/internal/obj/i386/list8.go index f62253976b9..104b97c755c 100644 --- a/src/cmd/internal/obj/i386/list8.go +++ b/src/cmd/internal/obj/i386/list8.go @@ -155,7 +155,7 @@ func init() { func Rconv(r int) string { if r >= REG_AL && r-REG_AL < len(Register) { - return fmt.Sprintf("%s", Register[r-REG_AL]) + return Register[r-REG_AL] } return fmt.Sprintf("Rgok(%d)", r-obj.RBase386) } diff --git a/src/cmd/internal/obj/obj.go b/src/cmd/internal/obj/obj.go index 05902e2e33f..980a0e4a38c 100644 --- a/src/cmd/internal/obj/obj.go +++ b/src/cmd/internal/obj/obj.go @@ -183,16 +183,16 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) { } var buf string if filepath.IsAbs(file) || strings.HasPrefix(file, "<") { - buf = fmt.Sprintf("%s", file) + buf = file } else { - buf = fmt.Sprintf("%s/%s", ctxt.Pathname, file) + buf = ctxt.Pathname + "/" + file } // Remove leading ctxt->trimpath, or else rewrite $GOROOT to $GOROOT_FINAL. if ctxt.Trimpath != "" && haspathprefix(buf, ctxt.Trimpath) { if len(buf) == len(ctxt.Trimpath) { buf = "??" } else { - buf1 := fmt.Sprintf("%s", buf[len(ctxt.Trimpath)+1:]) + buf1 := buf[len(ctxt.Trimpath)+1:] if buf1[0] == '\x00' { buf1 = "??" } diff --git a/src/cmd/internal/obj/x86/list6.go b/src/cmd/internal/obj/x86/list6.go index 6b7d65cbae5..7cb79af7f64 100644 --- a/src/cmd/internal/obj/x86/list6.go +++ b/src/cmd/internal/obj/x86/list6.go @@ -211,7 +211,7 @@ func init() { func Rconv(r int) string { if REG_AL <= r && r-REG_AL < len(Register) { - return fmt.Sprintf("%s", Register[r-REG_AL]) + return Register[r-REG_AL] } return fmt.Sprintf("Rgok(%d)", r-obj.RBaseAMD64) }