mirror of
https://github.com/golang/go
synced 2024-11-24 01:30:10 -07:00
cmd/internal/gc, cmd/internal/obj: remove pointless fmt.Sprintf calls
This is a follow-up to CL 6265. No behavior changes. The diff was generated with eg, using template: package p import "fmt" func before(a string) string { return fmt.Sprintf(a) } func after(a string) string { return a } Change-Id: I7b3bebf31be5cd1ae2233da06cb4502a3d73f092 Reviewed-on: https://go-review.googlesource.com/6269 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
b1c0d8a54b
commit
05ca0f3370
@ -141,7 +141,7 @@ func Qconv(bits Bits, flag int) string {
|
|||||||
if first != 0 {
|
if first != 0 {
|
||||||
first = 0
|
first = 0
|
||||||
} else {
|
} else {
|
||||||
fp += fmt.Sprintf(" ")
|
fp += " "
|
||||||
}
|
}
|
||||||
if var_[i].node == nil || var_[i].node.Sym == nil {
|
if var_[i].node == nil || var_[i].node.Sym == nil {
|
||||||
fp += fmt.Sprintf("$%d", i)
|
fp += fmt.Sprintf("$%d", i)
|
||||||
|
@ -242,17 +242,17 @@ func Jconv(n *Node, flag int) string {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case EscHeap:
|
case EscHeap:
|
||||||
fp += fmt.Sprintf(" esc(h)")
|
fp += " esc(h)"
|
||||||
|
|
||||||
case EscScope:
|
case EscScope:
|
||||||
fp += fmt.Sprintf(" esc(s)")
|
fp += " esc(s)"
|
||||||
|
|
||||||
case EscNone:
|
case EscNone:
|
||||||
fp += fmt.Sprintf(" esc(no)")
|
fp += " esc(no)"
|
||||||
|
|
||||||
case EscNever:
|
case EscNever:
|
||||||
if c == 0 {
|
if c == 0 {
|
||||||
fp += fmt.Sprintf(" esc(N)")
|
fp += " esc(N)"
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -284,11 +284,11 @@ func Jconv(n *Node, flag int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if n.Addrtaken != 0 {
|
if n.Addrtaken != 0 {
|
||||||
fp += fmt.Sprintf(" addrtaken")
|
fp += " addrtaken"
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.Assigned != 0 {
|
if n.Assigned != 0 {
|
||||||
fp += fmt.Sprintf(" assigned")
|
fp += " assigned"
|
||||||
}
|
}
|
||||||
|
|
||||||
if c == 0 && n.Used != 0 {
|
if c == 0 && n.Used != 0 {
|
||||||
@ -820,10 +820,10 @@ func typefmt(t *Type, flag int) string {
|
|||||||
|
|
||||||
case TUNSAFEPTR:
|
case TUNSAFEPTR:
|
||||||
if fmtmode == FExp {
|
if fmtmode == FExp {
|
||||||
fp += fmt.Sprintf("@\"unsafe\".Pointer")
|
fp += "@\"unsafe\".Pointer"
|
||||||
return fp
|
return fp
|
||||||
}
|
}
|
||||||
fp += fmt.Sprintf("unsafe.Pointer")
|
fp += "unsafe.Pointer"
|
||||||
return fp
|
return fp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,7 +1184,7 @@ func exprfmt(n *Node, prec int) string {
|
|||||||
|
|
||||||
case ODDDARG:
|
case ODDDARG:
|
||||||
var f string
|
var f string
|
||||||
f += fmt.Sprintf("... argument")
|
f += "... argument"
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case OREGISTER:
|
case OREGISTER:
|
||||||
@ -1217,7 +1217,7 @@ func exprfmt(n *Node, prec int) string {
|
|||||||
// _ becomes ~b%d internally; print as _ for export
|
// _ becomes ~b%d internally; print as _ for export
|
||||||
case ONAME:
|
case ONAME:
|
||||||
if fmtmode == FExp && n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
|
if fmtmode == FExp && n.Sym != nil && n.Sym.Name[0] == '~' && n.Sym.Name[1] == 'b' {
|
||||||
return fmt.Sprintf("_")
|
return "_"
|
||||||
}
|
}
|
||||||
if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Vargen > 0 {
|
if fmtmode == FExp && n.Sym != nil && !isblank(n) && n.Vargen > 0 {
|
||||||
return fmt.Sprintf("%v·%d", Sconv(n.Sym, 0), n.Vargen)
|
return fmt.Sprintf("%v·%d", Sconv(n.Sym, 0), n.Vargen)
|
||||||
@ -1286,17 +1286,17 @@ func exprfmt(n *Node, prec int) string {
|
|||||||
|
|
||||||
case OTSTRUCT:
|
case OTSTRUCT:
|
||||||
var f string
|
var f string
|
||||||
f += fmt.Sprintf("<struct>")
|
f += "<struct>"
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case OTINTER:
|
case OTINTER:
|
||||||
var f string
|
var f string
|
||||||
f += fmt.Sprintf("<inter>")
|
f += "<inter>"
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case OTFUNC:
|
case OTFUNC:
|
||||||
var f string
|
var f string
|
||||||
f += fmt.Sprintf("<func>")
|
f += "<func>"
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case OCLOSURE:
|
case OCLOSURE:
|
||||||
@ -1565,7 +1565,7 @@ func exprfmt(n *Node, prec int) string {
|
|||||||
var f string
|
var f string
|
||||||
for l := n.List; l != nil; l = l.Next {
|
for l := n.List; l != nil; l = l.Next {
|
||||||
if l != n.List {
|
if l != n.List {
|
||||||
f += fmt.Sprintf(" + ")
|
f += " + "
|
||||||
}
|
}
|
||||||
f += exprfmt(l.N, nprec)
|
f += exprfmt(l.N, nprec)
|
||||||
}
|
}
|
||||||
@ -1596,7 +1596,7 @@ func nodefmt(n *Node, flag int) string {
|
|||||||
|
|
||||||
if flag&obj.FmtLong != 0 /*untyped*/ && t != nil {
|
if flag&obj.FmtLong != 0 /*untyped*/ && t != nil {
|
||||||
if t.Etype == TNIL {
|
if t.Etype == TNIL {
|
||||||
return fmt.Sprintf("nil")
|
return "nil"
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("%v (type %v)", Nconv(n, 0), Tconv(t, 0))
|
return fmt.Sprintf("%v (type %v)", Nconv(n, 0), Tconv(t, 0))
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ func fninit(n *NodeList) {
|
|||||||
r := (*NodeList)(nil)
|
r := (*NodeList)(nil)
|
||||||
|
|
||||||
// (1)
|
// (1)
|
||||||
namebuf = fmt.Sprintf("initdone·")
|
namebuf = "initdone·"
|
||||||
|
|
||||||
gatevar := newname(Lookup(namebuf))
|
gatevar := newname(Lookup(namebuf))
|
||||||
addvar(gatevar, Types[TUINT8], PEXTERN)
|
addvar(gatevar, Types[TUINT8], PEXTERN)
|
||||||
@ -126,7 +126,7 @@ func fninit(n *NodeList) {
|
|||||||
// (2)
|
// (2)
|
||||||
Maxarg = 0
|
Maxarg = 0
|
||||||
|
|
||||||
namebuf = fmt.Sprintf("init")
|
namebuf = "init"
|
||||||
|
|
||||||
fn := Nod(ODCLFUNC, nil, nil)
|
fn := Nod(ODCLFUNC, nil, nil)
|
||||||
initsym := Lookup(namebuf)
|
initsym := Lookup(namebuf)
|
||||||
|
@ -608,7 +608,7 @@ func Fconv(fvp *Mpflt, flag int) string {
|
|||||||
if -900 < exp && exp < 900 {
|
if -900 < exp && exp < 900 {
|
||||||
d := mpgetflt(fvp)
|
d := mpgetflt(fvp)
|
||||||
if d >= 0 && (flag&obj.FmtSign != 0 /*untyped*/) {
|
if d >= 0 && (flag&obj.FmtSign != 0 /*untyped*/) {
|
||||||
fp += fmt.Sprintf("+")
|
fp += "+"
|
||||||
}
|
}
|
||||||
fp += fmt.Sprintf("%.6g", d)
|
fp += fmt.Sprintf("%.6g", d)
|
||||||
return fp
|
return fp
|
||||||
@ -632,9 +632,9 @@ func Fconv(fvp *Mpflt, flag int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fvp.Val.Neg != 0 {
|
if fvp.Val.Neg != 0 {
|
||||||
fp += fmt.Sprintf("-")
|
fp += "-"
|
||||||
} else if flag&obj.FmtSign != 0 /*untyped*/ {
|
} else if flag&obj.FmtSign != 0 /*untyped*/ {
|
||||||
fp += fmt.Sprintf("+")
|
fp += "+"
|
||||||
}
|
}
|
||||||
fp += fmt.Sprintf("%.5fe+%d", d, exp)
|
fp += fmt.Sprintf("%.5fe+%d", d, exp)
|
||||||
return fp
|
return fp
|
||||||
@ -643,7 +643,7 @@ func Fconv(fvp *Mpflt, flag int) string {
|
|||||||
var fv Mpflt
|
var fv Mpflt
|
||||||
var buf string
|
var buf string
|
||||||
if sigfig(fvp) == 0 {
|
if sigfig(fvp) == 0 {
|
||||||
buf = fmt.Sprintf("0p+0")
|
buf = "0p+0"
|
||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,7 +1475,7 @@ func livenessepilogue(lv *Liveness) {
|
|||||||
if p.As == obj.ACALL && p.To.Node != nil {
|
if p.As == obj.ACALL && p.To.Node != nil {
|
||||||
fmt_ += fmt.Sprintf("call to %s:", ((p.To.Node).(*Node)).Sym.Name)
|
fmt_ += fmt.Sprintf("call to %s:", ((p.To.Node).(*Node)).Sym.Name)
|
||||||
} else if p.As == obj.ACALL {
|
} else if p.As == obj.ACALL {
|
||||||
fmt_ += fmt.Sprintf("indirect call:")
|
fmt_ += "indirect call:"
|
||||||
} else {
|
} else {
|
||||||
fmt_ += fmt.Sprintf("entry to %s:", ((p.From.Node).(*Node)).Sym.Name)
|
fmt_ += fmt.Sprintf("entry to %s:", ((p.From.Node).(*Node)).Sym.Name)
|
||||||
}
|
}
|
||||||
@ -1488,7 +1488,7 @@ func livenessepilogue(lv *Liveness) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt_ += fmt.Sprintf("\n")
|
fmt_ += "\n"
|
||||||
if numlive == 0 { // squelch message
|
if numlive == 0 { // squelch message
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1729,9 +1729,9 @@ func badtype(o int, tl *Type, tr *Type) {
|
|||||||
// common mistake: *struct and *interface.
|
// common mistake: *struct and *interface.
|
||||||
if tl != nil && tr != nil && Isptr[tl.Etype] != 0 && Isptr[tr.Etype] != 0 {
|
if tl != nil && tr != nil && Isptr[tl.Etype] != 0 && Isptr[tr.Etype] != 0 {
|
||||||
if tl.Type.Etype == TSTRUCT && tr.Type.Etype == TINTER {
|
if tl.Type.Etype == TSTRUCT && tr.Type.Etype == TINTER {
|
||||||
fmt_ += fmt.Sprintf("\n\t(*struct vs *interface)")
|
fmt_ += "\n\t(*struct vs *interface)"
|
||||||
} else if tl.Type.Etype == TINTER && tr.Type.Etype == TSTRUCT {
|
} else if tl.Type.Etype == TINTER && tr.Type.Etype == TSTRUCT {
|
||||||
fmt_ += fmt.Sprintf("\n\t(*interface vs *struct)")
|
fmt_ += "\n\t(*interface vs *struct)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1796,13 +1796,13 @@ func dumptypes(nl **Type, what string) string {
|
|||||||
var savel Iter
|
var savel Iter
|
||||||
|
|
||||||
fmt_ := ""
|
fmt_ := ""
|
||||||
fmt_ += fmt.Sprintf("\t")
|
fmt_ += "\t"
|
||||||
first := 1
|
first := 1
|
||||||
for l := Structfirst(&savel, nl); l != nil; l = structnext(&savel) {
|
for l := Structfirst(&savel, nl); l != nil; l = structnext(&savel) {
|
||||||
if first != 0 {
|
if first != 0 {
|
||||||
first = 0
|
first = 0
|
||||||
} else {
|
} else {
|
||||||
fmt_ += fmt.Sprintf(", ")
|
fmt_ += ", "
|
||||||
}
|
}
|
||||||
fmt_ += fmt.Sprintf("%v", Tconv(l, 0))
|
fmt_ += fmt.Sprintf("%v", Tconv(l, 0))
|
||||||
}
|
}
|
||||||
@ -1817,14 +1817,14 @@ func dumpnodetypes(l *NodeList, what string) string {
|
|||||||
var r *Node
|
var r *Node
|
||||||
|
|
||||||
fmt_ := ""
|
fmt_ := ""
|
||||||
fmt_ += fmt.Sprintf("\t")
|
fmt_ += "\t"
|
||||||
first := 1
|
first := 1
|
||||||
for ; l != nil; l = l.Next {
|
for ; l != nil; l = l.Next {
|
||||||
r = l.N
|
r = l.N
|
||||||
if first != 0 {
|
if first != 0 {
|
||||||
first = 0
|
first = 0
|
||||||
} else {
|
} else {
|
||||||
fmt_ += fmt.Sprintf(", ")
|
fmt_ += ", "
|
||||||
}
|
}
|
||||||
fmt_ += fmt.Sprintf("%v", Tconv(r.Type, 0))
|
fmt_ += fmt.Sprintf("%v", Tconv(r.Type, 0))
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func (p *Prog) Line() string {
|
|||||||
|
|
||||||
func (p *Prog) String() string {
|
func (p *Prog) String() string {
|
||||||
if p.Ctxt == nil {
|
if p.Ctxt == nil {
|
||||||
return fmt.Sprintf("<Prog without ctxt>")
|
return "<Prog without ctxt>"
|
||||||
}
|
}
|
||||||
return p.Ctxt.Arch.Pconv(p)
|
return p.Ctxt.Arch.Pconv(p)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user