mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: optimize condition for unless
* parse.y (new_unless): optimize constant condition for `unless` as well as `if`. [Fix GH-1092] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7765e2e63b
commit
aa4ab1814d
2 changed files with 8 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Nov 13 10:36:39 2015 Victor Nawothnig <Victor.Nawothnig@gmail.com>
|
||||
|
||||
* parse.y (new_unless): optimize constant condition for `unless`
|
||||
as well as `if`. [Fix GH-1092]
|
||||
|
||||
Fri Nov 13 10:08:41 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* ext/psych/psych.gemspec: bump version to 2.0.15
|
||||
|
|
5
parse.y
5
parse.y
|
@ -387,6 +387,7 @@ static NODE *cond_gen(struct parser_params*,NODE*);
|
|||
#define cond(node) cond_gen(parser, (node))
|
||||
static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*);
|
||||
#define new_if(cc,left,right) new_if_gen(parser, (cc), (left), (right))
|
||||
#define new_unless(cc,left,right) new_if_gen(parser, (cc), (right), (left))
|
||||
static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*);
|
||||
#define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
|
||||
|
||||
|
@ -1177,7 +1178,7 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
|
|||
| stmt modifier_unless expr_value
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = NEW_UNLESS(cond($3), remove_begin($1), 0);
|
||||
$$ = new_unless($3, remove_begin($1), 0);
|
||||
fixpos($$, $3);
|
||||
/*%
|
||||
$$ = dispatch2(unless_mod, $3, $1);
|
||||
|
@ -2851,7 +2852,7 @@ primary : literal
|
|||
k_end
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = NEW_UNLESS(cond($2), $4, $5);
|
||||
$$ = new_unless($2, $4, $5);
|
||||
fixpos($$, $2);
|
||||
/*%
|
||||
$$ = dispatch3(unless, $2, $4, escape_Qundef($5));
|
||||
|
|
Loading…
Reference in a new issue