From 337cc2915625728021eaf113fe54e83a5a05530e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6hrmann?= Date: Sun, 6 May 2018 20:18:52 +0200 Subject: [PATCH] cmd/compile: simplify extendslice and isAppendOfMake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia66361812837dde23aac09e916f058ba509a323c Reviewed-on: https://go-review.googlesource.com/111737 Run-TryBot: Martin Möhrmann TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder --- src/cmd/compile/internal/gc/walk.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index ead578fb33..69e9d5b4e1 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -3054,11 +3054,7 @@ func isAppendOfMake(n *Node) bool { } second := n.List.Second() - if second.Op != OMAKESLICE { - return false - } - - if n.List.Second().Right != nil { + if second.Op != OMAKESLICE || second.Right != nil { return false } @@ -3135,10 +3131,8 @@ func extendslice(n *Node, init *Nodes) *Node { nodes = append(nodes, nod(OAS, nn, nod(OADD, nod(OLEN, s, nil), l2))) // if uint(n) > uint(cap(s)) - nuint := nod(OCONV, nn, nil) - nuint.Type = types.Types[TUINT] - capuint := nod(OCONV, nod(OCAP, s, nil), nil) - capuint.Type = types.Types[TUINT] + nuint := conv(nn, types.Types[TUINT]) + capuint := conv(nod(OCAP, s, nil), types.Types[TUINT]) nif := nod(OIF, nod(OGT, nuint, capuint), nil) // instantiate growslice(typ *type, old []any, newcap int) []any