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

ruby-changes:41932

From: nobu <ko1@a...>
Date: Sat, 5 Mar 2016 10:33:09 +0900 (JST)
Subject: [ruby-changes:41932] nobu:r54006 (trunk): parse.y: optimize negate_lit

nobu	2016-03-05 10:33:04 +0900 (Sat, 05 Mar 2016)

  New Revision: 54006

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

  Log:
    parse.y: optimize negate_lit
    
    * parse.y (negate_lit): optimize bignum, rational, and complex
      negation.

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 54005)
+++ parse.y	(revision 54006)
@@ -10014,9 +10014,15 @@ negate_lit(VALUE lit) https://github.com/ruby/ruby/blob/trunk/parse.y#L10014
 	lit = LONG2FIX(-FIX2LONG(lit));
 	break;
       case T_BIGNUM:
+	BIGNUM_NEGATE(lit);
+	lit = rb_big_norm(lit);
+	break;
       case T_RATIONAL:
+	RRATIONAL_SET_NUM(lit, negate_lit(RRATIONAL(lit)->num));
+	break;
       case T_COMPLEX:
-	lit = rb_funcallv(lit, tUMINUS, 0, 0);
+	RCOMPLEX_SET_REAL(lit, negate_lit(RCOMPLEX(lit)->real));
+	RCOMPLEX_SET_IMAG(lit, negate_lit(RCOMPLEX(lit)->imag));
 	break;
       case T_FLOAT:
 #if USE_FLONUM

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

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