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

numeric.c: optimize for Bignum

* numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for
  Bignum.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-03-05 01:18:55 +00:00
parent 66867b0a63
commit ce357ef152
2 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 5 10:19:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for
Bignum.
Tue Mar 5 10:02:48 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rubygems/ext/ext_conf_builder.rb (Gem::Ext::ExtConfBuilder.build):

View file

@ -2390,6 +2390,9 @@ int_succ(VALUE num)
long i = FIX2LONG(num) + 1;
return LONG2NUM(i);
}
if (RB_TYPE_P(num, T_BIGNUM)) {
return rb_big_plus(num, INT2FIX(1));
}
return rb_funcall(num, '+', 1, INT2FIX(1));
}
@ -2410,6 +2413,9 @@ int_pred(VALUE num)
long i = FIX2LONG(num) - 1;
return LONG2NUM(i);
}
if (RB_TYPE_P(num, T_BIGNUM)) {
return rb_big_minus(num, INT2FIX(1));
}
return rb_funcall(num, '-', 1, INT2FIX(1));
}