diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-05 01:33:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-05 01:33:04 +0000 |
commit | 53fbaeab29da70a4dd7318f7b5879817de2cbd61 (patch) | |
tree | 546fd93f3a881ee34870a291b8cd75b36680a8b5 /parse.y | |
parent | bf5d2c74c9005a095a7c300f8c858a2ba5171307 (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
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |