From a40171857595db60e95a04b64aad8ba262cf64a7 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 27 Jul 2020 16:45:48 -0700 Subject: [PATCH] cmd/compile/internal/gc: cleanup walkselectcases slightly Remove some unnecessary code. Most significantly, we can skip testing "if ch == nil { block() }", because this is already the semantics implied by normal send/receive operations. Updates #40410. Change-Id: I4acd33383cc876719fc3b998d85244d4ac1ff9d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/245126 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/gc/select.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/cmd/compile/internal/gc/select.go b/src/cmd/compile/internal/gc/select.go index bae7ed30e24..3812a0e1faa 100644 --- a/src/cmd/compile/internal/gc/select.go +++ b/src/cmd/compile/internal/gc/select.go @@ -123,17 +123,14 @@ func walkselectcases(cases *Nodes) []*Node { n := cas.Left l = append(l, n.Ninit.Slice()...) n.Ninit.Set(nil) - var ch *Node switch n.Op { default: Fatalf("select %v", n.Op) - // ok already case OSEND: - ch = n.Left + // already ok case OSELRECV, OSELRECV2: - ch = n.Right.Left if n.Op == OSELRECV || n.List.Len() == 0 { if n.Left == nil { n = n.Right @@ -157,16 +154,7 @@ func walkselectcases(cases *Nodes) []*Node { n = typecheck(n, ctxStmt) } - // if ch == nil { block() }; n; - a := nod(OIF, nil, nil) - - a.Left = nod(OEQ, ch, nodnil()) - var ln Nodes - ln.Set(l) - a.Nbody.Set1(mkcall("block", nil, &ln)) - l = ln.Slice() - a = typecheck(a, ctxStmt) - l = append(l, a, n) + l = append(l, n) } l = append(l, cas.Nbody.Slice()...) @@ -223,8 +211,6 @@ func walkselectcases(cases *Nodes) []*Node { case OSELRECV: // if selectnbrecv(&v, c) { body } else { default body } - r = nod(OIF, nil, nil) - r.Ninit.Set(cas.Ninit.Slice()) ch := n.Right.Left elem := n.Left if elem == nil { @@ -234,8 +220,6 @@ func walkselectcases(cases *Nodes) []*Node { case OSELRECV2: // if selectnbrecv2(&v, &received, c) { body } else { default body } - r = nod(OIF, nil, nil) - r.Ninit.Set(cas.Ninit.Slice()) ch := n.Right.Left elem := n.Left if elem == nil {