1
0
mirror of https://github.com/golang/go synced 2024-11-23 13:20:09 -07:00

cmd/compile: use Bool accessor in place of Val.U.(bool)

We have a Bool() accessor for the value in boolean nodes, that we use
elsewhere for n.Val().U.(bool), use it here too. Noticed while reading
the code.

Change-Id: Ie42e014970099a05fe9f02f378af77b63e7e6b13
Reviewed-on: https://go-review.googlesource.com/c/go/+/261360
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Alberto Donizetti 2020-10-12 14:35:24 +02:00 committed by Robert Griesemer
parent 2e7706d1fa
commit 349a287646

View File

@ -440,7 +440,7 @@ func (c *exprClause) test(exprname *Node) *Node {
// Optimize "switch true { ...}" and "switch false { ... }". // Optimize "switch true { ...}" and "switch false { ... }".
if Isconst(exprname, CTBOOL) && !c.lo.Type.IsInterface() { if Isconst(exprname, CTBOOL) && !c.lo.Type.IsInterface() {
if exprname.Val().U.(bool) { if exprname.Bool() {
return c.lo return c.lo
} else { } else {
return nodl(c.pos, ONOT, c.lo, nil) return nodl(c.pos, ONOT, c.lo, nil)