* enum.c (enum_inject): Implement the specialied code for :+ operator
for Fixnums. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
95d2ec93bc
commit
43e20c6a9a
@ -1,3 +1,8 @@
|
|||||||
|
Tue Mar 15 20:32:57 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* enum.c (enum_inject): Implement the specialied code for :+ operator
|
||||||
|
for Fixnums.
|
||||||
|
|
||||||
Tue Mar 15 20:21:01 2016 Tanaka Akira <akr@fsij.org>
|
Tue Mar 15 20:21:01 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* enum.c (enum_inject): Implement the specialized code for self is an
|
* enum.c (enum_inject): Implement the specialized code for self is an
|
||||||
|
11
enum.c
11
enum.c
@ -719,6 +719,17 @@ enum_inject(int argc, VALUE *argv, VALUE obj)
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
id = SYM2ID(op);
|
id = SYM2ID(op);
|
||||||
|
if (id == idPLUS && FIXNUM_P(v)) {
|
||||||
|
long n = FIX2LONG(v);
|
||||||
|
while (i < RARRAY_LEN(obj)) {
|
||||||
|
VALUE e = RARRAY_AREF(obj, i);
|
||||||
|
if (!FIXNUM_P(e)) break;
|
||||||
|
n += FIX2LONG(e); /* should not overflow long type */
|
||||||
|
i++;
|
||||||
|
if (!FIXABLE(n)) break;
|
||||||
|
}
|
||||||
|
v = LONG2NUM(n);
|
||||||
|
}
|
||||||
for (; i<RARRAY_LEN(obj); i++) {
|
for (; i<RARRAY_LEN(obj); i++) {
|
||||||
v = rb_funcall(v, id, 1, RARRAY_AREF(obj, i));
|
v = rb_funcall(v, id, 1, RARRAY_AREF(obj, i));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user