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 | 68203fd2f228b960c02f2e0a7ca49309837285ff (patch) | |
tree | 546fd93f3a881ee34870a291b8cd75b36680a8b5 | |
parent | 808068193d7c8697dd2c395b85f5e241e5e691a1 (diff) | |
download | ruby-68203fd2f228b960c02f2e0a7ca49309837285ff.tar.gz |
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.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 |