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:
parent
bf5d2c74c9
commit
53fbaeab29
1 changed files with 7 additions and 1 deletions
8
parse.y
8
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
|
||||
|
|
Loading…
Add table
Reference in a new issue