[前][次][番号順一覧][スレッド一覧]

ruby-changes:40472

From: nobu <ko1@a...>
Date: Fri, 13 Nov 2015 10:36:51 +0900 (JST)
Subject: [ruby-changes:40472] nobu:r52553 (trunk): parse.y: optimize condition for unless

nobu	2015-11-13 10:36:42 +0900 (Fri, 13 Nov 2015)

  New Revision: 52553

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52553

  Log:
    parse.y: optimize condition for unless
    
    * parse.y (new_unless): optimize constant condition for `unless`
      as well as `if`.  [Fix GH-1092]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52552)
+++ ChangeLog	(revision 52553)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov 13 10:36:39 2015  Victor Nawothnig  <Victor.Nawothnig@g...>
+
+	* 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@r...>
 
 	* ext/psych/psych.gemspec: bump version to 2.0.15
Index: parse.y
===================================================================
--- parse.y	(revision 52552)
+++ parse.y	(revision 52553)
@@ -387,6 +387,7 @@ static NODE *cond_gen(struct parser_para https://github.com/ruby/ruby/blob/trunk/parse.y#L387
 #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 = https://github.com/ruby/ruby/blob/trunk/parse.y#L1178
 		| 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 https://github.com/ruby/ruby/blob/trunk/parse.y#L2852
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_UNLESS(cond($2), $4, $5);
+			$$ = new_unless($2, $4, $5);
 			fixpos($$, $2);
 		    /*%
 			$$ = dispatch3(unless, $2, $4, escape_Qundef($5));

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]