зеркало из https://github.com/github/ruby.git
* insns.def (opt_mod): Use % operator if both operands are positive for
a significant performance improvement. Thanks to @samsaffron. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e9b63c1a22
Коммит
4f683e1678
|
@ -1,3 +1,8 @@
|
|||
Mon Apr 22 22:54:00 2013 Charlie Somerville <charlie@charliesomerville.com>
|
||||
|
||||
* insns.def (opt_mod): Use % operator if both operands are positive for
|
||||
a significant performance improvement. Thanks to @samsaffron.
|
||||
|
||||
Mon Apr 22 17:09:37 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* marshal.c (r_object0): copy all instance variables not only generic
|
||||
|
|
10
insns.def
10
insns.def
|
@ -1524,13 +1524,15 @@ opt_mod
|
|||
{
|
||||
if (FIXNUM_2_P(recv, obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MOD, FIXNUM_REDEFINED_OP_FLAG )) {
|
||||
long x, y, mod;
|
||||
long x, y;
|
||||
|
||||
x = FIX2LONG(recv);
|
||||
y = FIX2LONG(obj);
|
||||
{
|
||||
if (x > 0 && y > 0) {
|
||||
val = LONG2FIX(x % y);
|
||||
} else {
|
||||
/* copied from numeric.c#fixdivmod */
|
||||
long div;
|
||||
long div, mod;
|
||||
|
||||
if (y == 0)
|
||||
rb_num_zerodiv();
|
||||
|
@ -1551,8 +1553,8 @@ opt_mod
|
|||
mod += y;
|
||||
div -= 1;
|
||||
}
|
||||
val = LONG2FIX(mod);
|
||||
}
|
||||
val = LONG2FIX(mod);
|
||||
}
|
||||
else if (FLONUM_2_P(recv, obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MOD, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче