diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 01:36:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 01:36:42 +0000 |
commit | aa4ab1814d868e1002e009174944e4f85d2b7448 (patch) | |
tree | 198c0e3776e6c8786231c36b1c078ee0b39a9365 | |
parent | 7765e2e63b71e1239ae4c0894895a735061e204d (diff) | |
download | ruby-aa4ab1814d868e1002e009174944e4f85d2b7448.tar.gz |
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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 5 |
2 files changed, 8 insertions, 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 @@ -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)); |