* hash.c (rb_hash_flatten): performance improvement by not using
rb_hash_to_a() to avoid array creation with rb_assoc_new(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
852caed8a3
commit
6f49bc635b
@ -1,3 +1,8 @@
|
|||||||
|
Thu Jul 18 18:14:36 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* array.c (rb_ary_count): iterate items appropriately.
|
||||||
|
[Bug #8654]
|
||||||
|
|
||||||
Thu Jul 18 17:35:41 2013 Masaki Matsushita <glass.saga@gmail.com>
|
Thu Jul 18 17:35:41 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
* hash.c (rb_hash_flatten): performance improvement by not using
|
* hash.c (rb_hash_flatten): performance improvement by not using
|
||||||
|
8
array.c
8
array.c
@ -4177,13 +4177,15 @@ rb_ary_count(int argc, VALUE *argv, VALUE ary)
|
|||||||
long n = 0;
|
long n = 0;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
VALUE *p, *pend;
|
long i;
|
||||||
|
VALUE v;
|
||||||
|
|
||||||
if (!rb_block_given_p())
|
if (!rb_block_given_p())
|
||||||
return LONG2NUM(RARRAY_LEN(ary));
|
return LONG2NUM(RARRAY_LEN(ary));
|
||||||
|
|
||||||
for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||||
if (RTEST(rb_yield(*p))) n++;
|
v = RARRAY_AREF(ary, i);
|
||||||
|
if (RTEST(rb_yield(v))) n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user