]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: replace len(Nodes.Slice()) with Nodes.Len()
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 24 Apr 2016 20:50:26 +0000 (13:50 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 25 Apr 2016 02:13:22 +0000 (02:13 +0000)
Generated with eg:

func before(n gc.Nodes) int { return len(n.Slice()) }
func after(n gc.Nodes) int  { return n.Len() }

Change-Id: Ifdf01915e60069166afe96aa7b1d08720bf62fc5
Reviewed-on: https://go-review.googlesource.com/22420
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
13 files changed:
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/parser.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/walk.go

index 6b83e70403ccec8a0d881741174296030d324d2c..f0907b45eb99206c58262035efe410faf6e2be8b 100644 (file)
@@ -528,7 +528,7 @@ func (p *exporter) pos(n *Node) {
 }
 
 func isInlineable(n *Node) bool {
-       if exportInlined && n != nil && n.Func != nil && len(n.Func.Inl.Slice()) != 0 {
+       if exportInlined && n != nil && n.Func != nil && n.Func.Inl.Len() != 0 {
                // when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
                // currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
                if Debug['l'] < 2 {
index cbd3fb0e87a3f2148789bd09c77253f6649d26f9..1219d8d37081e70cdefe044188ee675bc92ea63b 100644 (file)
@@ -271,7 +271,7 @@ func (p *importer) obj(tag int) {
 
                if Debug['E'] > 0 {
                        fmt.Printf("import [%q] func %v \n", importpkg.Path, n)
-                       if Debug['m'] > 2 && len(n.Func.Inl.Slice()) != 0 {
+                       if Debug['m'] > 2 && n.Func.Inl.Len() != 0 {
                                fmt.Printf("inl body: %v\n", n.Func.Inl)
                        }
                }
@@ -368,7 +368,7 @@ func (p *importer) typ() *Type {
 
                        if Debug['E'] > 0 {
                                fmt.Printf("import [%q] meth %v \n", importpkg.Path, n)
-                               if Debug['m'] > 2 && len(n.Func.Inl.Slice()) != 0 {
+                               if Debug['m'] > 2 && n.Func.Inl.Len() != 0 {
                                        fmt.Printf("inl body: %v\n", n.Func.Inl)
                                }
                        }
index db4eb3f14ddad2c0ae8de74ea429846cb9f25841..d2cb9ebf1e2463975ccf6c25770a6f4836f5b6df 100644 (file)
@@ -194,7 +194,7 @@ func makeclosure(func_ *Node) *Node {
        xfunc.Nbody.Set(func_.Nbody.Slice())
        xfunc.Func.Dcl = append(func_.Func.Dcl, xfunc.Func.Dcl...)
        func_.Func.Dcl = nil
-       if len(xfunc.Nbody.Slice()) == 0 {
+       if xfunc.Nbody.Len() == 0 {
                Fatalf("empty body - won't generate any code")
        }
        xfunc = typecheck(xfunc, Etop)
index d7a63668a67fdcda8e240182cd1f66d7c0d37b7a..2f4e5fb6ef279f3b362ba1117bbc6cacde091736 100644 (file)
@@ -522,7 +522,7 @@ func escfunc(e *EscState, func_ *Node) {
                        if ln.Type != nil && !haspointers(ln.Type) {
                                break
                        }
-                       if len(Curfn.Nbody.Slice()) == 0 && !Curfn.Noescape {
+                       if Curfn.Nbody.Len() == 0 && !Curfn.Noescape {
                                ln.Esc = EscHeap
                        } else {
                                ln.Esc = EscNone // prime for escflood later
@@ -1469,7 +1469,7 @@ func esccall(e *EscState, n *Node, up *Node) {
 
        nE := e.nodeEscState(n)
        if fn != nil && fn.Op == ONAME && fn.Class == PFUNC &&
-               fn.Name.Defn != nil && len(fn.Name.Defn.Nbody.Slice()) != 0 && fn.Name.Param.Ntype != nil && fn.Name.Defn.Esc < EscFuncTagged {
+               fn.Name.Defn != nil && fn.Name.Defn.Nbody.Len() != 0 && fn.Name.Param.Ntype != nil && fn.Name.Defn.Esc < EscFuncTagged {
                if Debug['m'] > 3 {
                        fmt.Printf("%v::esccall:: %v in recursive group\n", linestr(lineno), Nconv(n, FmtShort))
                }
@@ -1969,7 +1969,7 @@ func esctag(e *EscState, func_ *Node) {
 
        // External functions are assumed unsafe,
        // unless //go:noescape is given before the declaration.
-       if len(func_.Nbody.Slice()) == 0 {
+       if func_.Nbody.Len() == 0 {
                if func_.Noescape {
                        for _, t := range func_.Type.Params().Fields().Slice() {
                                if haspointers(t.Type) {
index 1dd02aef1f042dac2472bc23804c034a56abebed..a275377598449bd05f33c5fd9d6b857ea05dd961 100644 (file)
@@ -252,7 +252,7 @@ func dumpexportvar(s *Sym) {
        dumpexporttype(t)
 
        if t.Etype == TFUNC && n.Class == PFUNC {
-               if n.Func != nil && len(n.Func.Inl.Slice()) != 0 {
+               if n.Func != nil && n.Func.Inl.Len() != 0 {
                        // when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
                        // currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
                        if Debug['l'] < 2 {
@@ -323,7 +323,7 @@ func dumpexporttype(t *Type) {
                if f.Nointerface {
                        exportf("\t//go:nointerface\n")
                }
-               if f.Type.Nname() != nil && len(f.Type.Nname().Func.Inl.Slice()) != 0 { // nname was set by caninl
+               if f.Type.Nname() != nil && f.Type.Nname().Func.Inl.Len() != 0 { // nname was set by caninl
 
                        // when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
                        // currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
index 9bba70964968db4ad3282d57abc4e8ccd401d0d9..12ae915fb2535457a43bbaadd9d9f528a5526094 100644 (file)
@@ -1196,7 +1196,7 @@ func exprfmt(n *Node, prec int) string {
                if fmtmode == FErr {
                        return "func literal"
                }
-               if len(n.Nbody.Slice()) != 0 {
+               if n.Nbody.Len() != 0 {
                        return fmt.Sprintf("%v { %v }", n.Type, n.Nbody)
                }
                return fmt.Sprintf("%v { %v }", n.Type, n.Name.Param.Closure.Nbody)
@@ -1577,7 +1577,7 @@ func nodedump(n *Node, flag FmtFlag) string {
                        fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist)
                }
 
-               if len(n.Nbody.Slice()) != 0 {
+               if n.Nbody.Len() != 0 {
                        indent(&buf)
                        fmt.Fprintf(&buf, "%v-body%v", Oconv(n.Op, 0), n.Nbody)
                }
index f9e425618baed3443af9ba69fa68d6a6a5ec5e94..da026e13963eaf5d61ff8bc0d60f2d4a7866e03f 100644 (file)
@@ -100,7 +100,7 @@ func caninl(fn *Node) {
        }
 
        // If fn has no body (is defined outside of Go), cannot inline it.
-       if len(fn.Nbody.Slice()) == 0 {
+       if fn.Nbody.Len() == 0 {
                return
        }
 
@@ -173,12 +173,12 @@ func ishairy(n *Node, budget *int) bool {
        switch n.Op {
        // Call is okay if inlinable and we have the budget for the body.
        case OCALLFUNC:
-               if n.Left.Func != nil && len(n.Left.Func.Inl.Slice()) != 0 {
+               if n.Left.Func != nil && n.Left.Func.Inl.Len() != 0 {
                        *budget -= int(n.Left.Func.InlCost)
                        break
                }
                if n.Left.Op == ONAME && n.Left.Left != nil && n.Left.Left.Op == OTYPE && n.Left.Right != nil && n.Left.Right.Op == ONAME { // methods called as functions
-                       if n.Left.Sym.Def != nil && len(n.Left.Sym.Def.Func.Inl.Slice()) != 0 {
+                       if n.Left.Sym.Def != nil && n.Left.Sym.Def.Func.Inl.Len() != 0 {
                                *budget -= int(n.Left.Sym.Def.Func.InlCost)
                                break
                        }
@@ -195,7 +195,7 @@ func ishairy(n *Node, budget *int) bool {
                if n.Left.Type.Nname() == nil {
                        Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, FmtSign))
                }
-               if len(n.Left.Type.Nname().Func.Inl.Slice()) != 0 {
+               if n.Left.Type.Nname().Func.Inl.Len() != 0 {
                        *budget -= int(n.Left.Type.Nname().Func.InlCost)
                        break
                }
@@ -453,7 +453,7 @@ func inlnode(n *Node) *Node {
                if Debug['m'] > 3 {
                        fmt.Printf("%v:call to func %v\n", n.Line(), Nconv(n.Left, FmtSign))
                }
-               if n.Left.Func != nil && len(n.Left.Func.Inl.Slice()) != 0 && !isIntrinsicCall1(n) { // normal case
+               if n.Left.Func != nil && n.Left.Func.Inl.Len() != 0 && !isIntrinsicCall1(n) { // normal case
                        n = mkinlcall(n, n.Left, n.Isddd)
                } else if n.Left.Op == ONAME && n.Left.Left != nil && n.Left.Left.Op == OTYPE && n.Left.Right != nil && n.Left.Right.Op == ONAME { // methods called as functions
                        if n.Left.Sym.Def != nil {
@@ -520,7 +520,7 @@ var inlgen int
 //     n.Left = mkinlcall1(n.Left, fn, isddd)
 func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
        // For variadic fn.
-       if len(fn.Func.Inl.Slice()) == 0 {
+       if fn.Func.Inl.Len() == 0 {
                return n
        }
 
index f6de58462ecd1939c39c1f66a2d8afbc75cbfa7f..c3a0481ffd51df1b3bfa454a8dfa9cb26f3017d1 100644 (file)
@@ -412,7 +412,7 @@ func Main() {
                // Typecheck imported function bodies if debug['l'] > 1,
                // otherwise lazily when used or re-exported.
                for _, n := range importlist {
-                       if len(n.Func.Inl.Slice()) != 0 {
+                       if n.Func.Inl.Len() != 0 {
                                saveerrors()
                                typecheckinl(n)
                        }
index 2b9546f4f56503039eaaecad8873137b3f233456..00ba4308cb7465f06bc366695352157953ed5fcb 100644 (file)
@@ -1146,7 +1146,7 @@ func orderexpr(n *Node, order *Order, lhs *Node) *Node {
                }
 
        case OCLOSURE:
-               if n.Noescape && len(n.Func.Cvars.Slice()) > 0 {
+               if n.Noescape && n.Func.Cvars.Len() > 0 {
                        prealloc[n] = ordertemp(Types[TUINT8], order, false) // walk will fill in correct type
                }
 
index ae4b497b7b9929cc17c8f1212ce177a182bcf667..766f352d3394ffb720492235ac7e3ac4ed5000aa 100644 (file)
@@ -2906,7 +2906,7 @@ func (p *parser) hidden_import() {
 
                if Debug['E'] > 0 {
                        fmt.Printf("import [%q] func %v \n", importpkg.Path, s2)
-                       if Debug['m'] > 2 && len(s2.Func.Inl.Slice()) != 0 {
+                       if Debug['m'] > 2 && s2.Func.Inl.Len() != 0 {
                                fmt.Printf("inl body:%v\n", s2.Func.Inl)
                        }
                }
index 7b9b91e7b071d2dbc2e8247385275e74ccb7982b..bba4ff5e4838335b4ce5c32b7504d1f8a047b06f 100644 (file)
@@ -363,7 +363,7 @@ func compile(fn *Node) {
        Curfn = fn
        dowidth(Curfn.Type)
 
-       if len(fn.Nbody.Slice()) == 0 {
+       if fn.Nbody.Len() == 0 {
                if pure_go || strings.HasPrefix(fn.Func.Nname.Sym.Name, "init.") {
                        Yyerror("missing function body for %q", fn.Func.Nname.Sym.Name)
                        return
index 9bf4f58412b839764d8e586a26b0ee89adac3906..49b991c5a50d5fd3820f69e964525a5a87dacb3f 100644 (file)
@@ -3953,7 +3953,7 @@ func (n *Node) isterminating() bool {
 }
 
 func checkreturn(fn *Node) {
-       if fn.Type.Results().NumFields() != 0 && len(fn.Nbody.Slice()) != 0 {
+       if fn.Type.Results().NumFields() != 0 && fn.Nbody.Len() != 0 {
                markbreaklist(fn.Nbody, nil)
                if !fn.Nbody.isterminating() {
                        yyerrorl(fn.Func.Endlineno, "missing return at end of function")
index 7e160bdd94111ad61d752e0fdef3fc3c902b6804..04ccfad9710bbe5de8b736fdb21794ee9b8dc668 100644 (file)
@@ -70,7 +70,7 @@ func walk(fn *Node) {
        }
 
        heapmoves()
-       if Debug['W'] != 0 && len(Curfn.Func.Enter.Slice()) > 0 {
+       if Debug['W'] != 0 && Curfn.Func.Enter.Len() > 0 {
                s := fmt.Sprintf("enter %v", Curfn.Func.Nname.Sym)
                dumplist(s, Curfn.Func.Enter)
        }