1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-03-05 01:33:04 +00:00
parent bf5d2c74c9
commit 53fbaeab29

View file

@ -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