cmd/5g etc: merge simple case expressions onto fewer lines

The c2go translation left a lot of case expressions on separate lines.
Merge expressions onto single lines subject to these constraints:

* Max 4 clauses, all literals or names
* Don't move expressions with comments

The change was created by running http://play.golang.org/p/yHajs72h-g:

$ mergecase cmd/internal/{ld,gc,obj}/*.go cmd/internal/obj/*/*.go

Passes toolstash -cmp.

Change-Id: Iba41b390d302e5486e5dc6ba7599a92270676556
Reviewed-on: https://go-review.googlesource.com/7593
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Josh Bleecher Snyder 2015-04-01 09:38:44 -07:00
parent 2c20eda1d8
commit b09925b31d
45 changed files with 358 additions and 851 deletions

View file

@ -42,8 +42,7 @@ func init1(n *Node, out **NodeList) {
return
}
switch n.Class {
case PEXTERN,
PFUNC:
case PEXTERN, PFUNC:
break
default:
@ -172,10 +171,7 @@ func init1(n *Node, out **NodeList) {
*out = list(*out, n.Defn)
}
case OAS2FUNC,
OAS2MAPR,
OAS2DOTTYPE,
OAS2RECV:
case OAS2FUNC, OAS2MAPR, OAS2DOTTYPE, OAS2RECV:
if n.Defn.Initorder != InitNotStarted {
break
}
@ -244,9 +240,7 @@ func initreorder(l *NodeList, out **NodeList) {
for ; l != nil; l = l.Next {
n = l.N
switch n.Op {
case ODCLFUNC,
ODCLCONST,
ODCLTYPE:
case ODCLFUNC, ODCLCONST, ODCLTYPE:
continue
}
@ -333,9 +327,7 @@ func staticcopy(l *Node, r *Node, out **NodeList) bool {
break
// copy pointer
case OARRAYLIT,
OSTRUCTLIT,
OMAPLIT:
case OARRAYLIT, OSTRUCTLIT, OMAPLIT:
gdata(l, Nod(OADDR, r.Nname, nil), int(l.Type.Width))
return true
@ -430,9 +422,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
break
// Init pointer.
case OARRAYLIT,
OMAPLIT,
OSTRUCTLIT:
case OARRAYLIT, OMAPLIT, OSTRUCTLIT:
a := staticname(r.Left.Type, 1)
r.Nname = a
@ -1222,9 +1212,7 @@ func oaslit(n *Node, init **NodeList) bool {
// not a special composit literal assignment
return false
case OSTRUCTLIT,
OARRAYLIT,
OMAPLIT:
case OSTRUCTLIT, OARRAYLIT, OMAPLIT:
if vmatch1(n.Left, n.Right) {
// not a special composit literal assignment
return false
@ -1377,8 +1365,7 @@ func iszero(n *Node) bool {
case CTBOOL:
return n.Val.U.Bval == 0
case CTINT,
CTRUNE:
case CTINT, CTRUNE:
return mpcmpfixc(n.Val.U.Xval, 0) == 0
case CTFLT:
@ -1522,8 +1509,7 @@ func gen_as_init(n *Node) bool {
TFLOAT64:
gdata(&nam, nr, int(nr.Type.Width))
case TCOMPLEX64,
TCOMPLEX128:
case TCOMPLEX64, TCOMPLEX128:
gdatacomplex(&nam, nr.Val.U.Cval)
case TSTRING: