]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: inline checknil
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 10 Nov 2018 15:00:32 +0000 (07:00 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 26 Feb 2019 19:28:58 +0000 (19:28 +0000)
Now that checknil has only a single caller, inline it.

Passes toolstash-check.

Change-Id: I5b13596bef84dd9a3e7f4bff8560903f1e54acfb
Reviewed-on: https://go-review.googlesource.com/c/148829
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/subr.go

index 284ecdf457ce34499b3439dcb4889f34248ecf8f..6db0f02001598e22c9bffc4429b4ab37b85264fa 100644 (file)
@@ -523,8 +523,14 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
                // Trigger panic for method on nil interface now.
                // Otherwise it happens in the wrapper and is confusing.
                n.Left = cheapexpr(n.Left, init)
+               n.Left = walkexpr(n.Left, nil)
 
-               checknil(n.Left, init)
+               tab := nod(OITAB, n.Left, nil)
+               tab = typecheck(tab, ctxExpr)
+
+               c := nod(OCHECKNIL, tab, nil)
+               c.SetTypecheck(1)
+               init.Append(c)
        }
 
        typ := partialCallType(n)
index 3a261244d151aae891e0b2f7ad86ccf2a89db98a..775147bff774d4231d40c2676add50a845f82f30 100644 (file)
@@ -1829,18 +1829,6 @@ func isbadimport(path string, allowSpace bool) bool {
        return false
 }
 
-func checknil(x *Node, init *Nodes) {
-       x = walkexpr(x, nil) // caller has not done this yet
-       if x.Type.IsInterface() {
-               x = nod(OITAB, x, nil)
-               x = typecheck(x, ctxExpr)
-       }
-
-       n := nod(OCHECKNIL, x, nil)
-       n.SetTypecheck(1)
-       init.Append(n)
-}
-
 // Can this type be stored directly in an interface word?
 // Yes, if the representation is a single pointer.
 func isdirectiface(t *types.Type) bool {