summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-05 01:33:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-05 01:33:04 +0000
commit53fbaeab29da70a4dd7318f7b5879817de2cbd61 (patch)
tree546fd93f3a881ee34870a291b8cd75b36680a8b5
parentbf5d2c74c9005a095a7c300f8c858a2ba5171307 (diff)
parse.y: optimize negate_lit
* parse.y (negate_lit): optimize bignum, rational, and complex negation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y8
1 files changed, 7 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index 3c248d39ab..3b5f5f8ed8 100644
--- a/parse.y
+++ b/parse.y
@@ -10014,9 +10014,15 @@ negate_lit(VALUE lit)
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