]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: various minor cleanups
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 11 Jun 2018 08:11:29 +0000 (09:11 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 20 Aug 2018 13:27:53 +0000 (13:27 +0000)
Two funcs and a field were unused. Remove them.

A few statements could be made simpler.

importsym's pos parameter was unused, so remove it.

Finally, don't use printf-like funcs with constant strings that have no
formatting directives.

Change-Id: I415452249bf2168aa353ac4f3643dfc03017ee53
Reviewed-on: https://go-review.googlesource.com/117699
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
src/cmd/compile/internal/gc/bv.go
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/dwinl.go
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/mpint.go
src/cmd/compile/internal/gc/scope_test.go
src/cmd/compile/internal/gc/walk.go

index e9db35ede2a4e7a1dcda10ad05fd1c422908b904..5ddfd5f2caef2738c397c6915e5a677fc36a16ee 100644 (file)
@@ -227,17 +227,6 @@ type bvecSet struct {
        uniq  []bvec // unique bvecs, in insertion order
 }
 
-func newBvecSet(size int) bvecSet {
-       // bvecSet is a linear probing hash table.
-       // The hash table has 4n entries to keep the linear
-       // scan short.
-       index := make([]int, size*4)
-       for i := range index {
-               index[i] = -1
-       }
-       return bvecSet{index, nil}
-}
-
 func (m *bvecSet) grow() {
        // Allocate new index.
        n := len(m.index) * 2
index 2827543e31ebb37746a5f655be5aa2f2366ca047..ceb124e31e39c52865cfdc36d97e6ac47a0f781d 100644 (file)
@@ -766,7 +766,7 @@ func evconst(n *Node) {
                        v.U.(*Mpint).Neg()
 
                case OCOM_ | CTINT_:
-                       var et types.EType = Txxx
+                       et := Txxx
                        if nl.Type != nil {
                                et = nl.Type.Etype
                        }
index f5142810617dc5a950dc241916d35a3ed4dd62b1..d191b7ba6c84c4bbd4c33c05ee6b5cfc986aad9b 100644 (file)
@@ -142,7 +142,7 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
                                // return temps (~r%d) that were created during
                                // lowering, or unnamed params ("_").
                                v.ChildIndex = int32(synthCount)
-                               synthCount += 1
+                               synthCount++
                        }
                }
        }
index becc4e1f3b3840f6b9a8277bebcb92f71194a497..3aa7c390675a23abf9c526e12434546030f67b19 100644 (file)
@@ -88,7 +88,7 @@ func dumpexport(bout *bio.Writer) {
        }
 }
 
-func importsym(ipkg *types.Pkg, pos src.XPos, s *types.Sym, op Op) *Node {
+func importsym(ipkg *types.Pkg, s *types.Sym, op Op) *Node {
        n := asNode(s.PkgDef())
        if n == nil {
                // iimport should have created a stub ONONAME
@@ -113,7 +113,7 @@ func importsym(ipkg *types.Pkg, pos src.XPos, s *types.Sym, op Op) *Node {
 // If no such type has been declared yet, a forward declaration is returned.
 // ipkg is the package being imported
 func importtype(ipkg *types.Pkg, pos src.XPos, s *types.Sym) *types.Type {
-       n := importsym(ipkg, pos, s, OTYPE)
+       n := importsym(ipkg, s, OTYPE)
        if n.Op != OTYPE {
                t := types.New(TFORW)
                t.Sym = s
@@ -135,7 +135,7 @@ func importtype(ipkg *types.Pkg, pos src.XPos, s *types.Sym) *types.Type {
 // importobj declares symbol s as an imported object representable by op.
 // ipkg is the package being imported
 func importobj(ipkg *types.Pkg, pos src.XPos, s *types.Sym, op Op, ctxt Class, t *types.Type) *Node {
-       n := importsym(ipkg, pos, s, op)
+       n := importsym(ipkg, s, op)
        if n.Op != ONONAME {
                if n.Op == op && (n.Class() != ctxt || !eqtype(n.Type, t)) {
                        redeclare(lineno, s, fmt.Sprintf("during import %q", ipkg.Path))
index 3abbd15e162ce87f5d2bfddc94ca7d737fa92877..5ce284dc732ccc708ae1934e360363f8ccd1f3af 100644 (file)
@@ -595,7 +595,7 @@ func (p *iexporter) typOff(t *types.Type) uint64 {
        if !ok {
                w := p.newWriter()
                w.doTyp(t)
-               off = predeclReserved + uint64(w.flush())
+               off = predeclReserved + w.flush()
                p.typIndex[t] = off
        }
        return off
index 9f1ea2ab4bf772b6417e85c81af17aeeab76b2a4..da6f800ccd5d96d1615e377e42f839b6a94544a4 100644 (file)
@@ -341,7 +341,7 @@ func Main(archInit func(*Arch)) {
                        }
                        // display help about the -d option itself and quit
                        if name == "help" {
-                               fmt.Printf(debugHelpHeader)
+                               fmt.Print(debugHelpHeader)
                                maxLen := len("ssa/help")
                                for _, t := range debugtab {
                                        if len(t.name) > maxLen {
@@ -353,7 +353,7 @@ func Main(archInit func(*Arch)) {
                                }
                                // ssa options have their own help
                                fmt.Printf("\t%-*s\t%s\n", maxLen, "ssa/help", "print help about SSA debugging")
-                               fmt.Printf(debugHelpFooter)
+                               fmt.Print(debugHelpFooter)
                                os.Exit(0)
                        }
                        val, valstring, haveInt := 1, "", true
index e9471b2a21cb93a42c19113a655d406f95ba78e6..de47205435459296c83773e9163b8737aaaa7219 100644 (file)
@@ -299,8 +299,8 @@ func (a *Mpint) SetString(as string) {
        }
 }
 
-func (x *Mpint) String() string {
-       return bconv(x, 0)
+func (a *Mpint) String() string {
+       return bconv(a, 0)
 }
 
 func bconv(xval *Mpint, flag FmtFlag) string {
index 944a81e6700fff6b30e7ad15a0568d5c0639288a..e327dc02af2df236e93d5c3eafe54aff21b10ac1 100644 (file)
@@ -350,7 +350,6 @@ type scopexplainContext struct {
        dwarfData   *dwarf.Data
        dwarfReader *dwarf.Reader
        scopegen    int
-       lines       map[line][]int
 }
 
 // readScope reads the DW_TAG_lexical_block or the DW_TAG_subprogram in
index df7428a127fd50685a8c1586d2edc0f90ac91774..f75e729eb5508100f5a568bcdef83b9c248a2157 100644 (file)
@@ -2220,14 +2220,6 @@ func callnew(t *types.Type) *Node {
        return v
 }
 
-func iscallret(n *Node) bool {
-       if n == nil {
-               return false
-       }
-       n = outervalue(n)
-       return n.Op == OINDREGSP
-}
-
 // isReflectHeaderDataField reports whether l is an expression p.Data
 // where p has type reflect.SliceHeader or reflect.StringHeader.
 func isReflectHeaderDataField(l *Node) bool {