ruby-changes:38318
From: nobu <ko1@a...>
Date: Wed, 29 Apr 2015 12:49:21 +0900 (JST)
Subject: [ruby-changes:38318] nobu:r50399 (trunk): parse.y: simplified
nobu 2015-04-29 12:49:05 +0900 (Wed, 29 Apr 2015) New Revision: 50399 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50399 Log: parse.y: simplified * parse.y (primary): turned nested if-else blocks into a switch statement. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 50398) +++ parse.y (revision 50399) @@ -2908,23 +2908,23 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2908 NODE *m = NEW_ARGS_AUX(0, 0); NODE *args, *scope; - if (nd_type($2) == NODE_MASGN) { + switch (nd_type($2)) { + case NODE_MASGN: m->nd_next = node_assign($2, NEW_FOR(NEW_DVAR(id), 0, 0)); args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0)); - } - else { - if (nd_type($2) == NODE_LASGN || - nd_type($2) == NODE_DASGN || - nd_type($2) == NODE_DASGN_CURR) { - $2->nd_value = NEW_DVAR(id); - m->nd_plen = 1; - m->nd_next = $2; - args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0)); - } - else { - m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id)); - args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0)); - } + break; + case NODE_LASGN: + case NODE_DASGN: + case NODE_DASGN_CURR: + $2->nd_value = NEW_DVAR(id); + m->nd_plen = 1; + m->nd_next = $2; + args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0)); + break; + default: + m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id)); + args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0)); + break; } scope = NEW_NODE(NODE_SCOPE, tbl, $8, args); tbl[0] = 1; tbl[1] = id; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/