numeric.c: short circuit optimization

* numeric.c (fix_mul): short circuit when multiplication of Bignum
  and 0 or 1 not to make a Bignum unnecessarily.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-01-10 12:18:21 +00:00
parent 93ff30bfe5
commit 3c199bb700
1 changed files with 4 additions and 0 deletions

View File

@ -3569,6 +3569,10 @@ fix_mul(VALUE x, VALUE y)
return rb_fix_mul_fix(x, y);
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
switch (x) {
case INT2FIX(0): return x;
case INT2FIX(1): return y;
}
return rb_big_mul(y, x);
}
else if (RB_TYPE_P(y, T_FLOAT)) {