зеркало из https://github.com/github/ruby.git
* 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:
Родитель
852caed8a3
Коммит
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>
|
||||
|
||||
* 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;
|
||||
|
||||
if (argc == 0) {
|
||||
VALUE *p, *pend;
|
||||
long i;
|
||||
VALUE v;
|
||||
|
||||
if (!rb_block_given_p())
|
||||
return LONG2NUM(RARRAY_LEN(ary));
|
||||
|
||||
for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
|
||||
if (RTEST(rb_yield(*p))) n++;
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
v = RARRAY_AREF(ary, i);
|
||||
if (RTEST(rb_yield(v))) n++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче