summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-18 09:18:50 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-18 09:18:50 +0000
commit6f49bc635bd6b0f049d4dacc2b9e46ff82d24866 (patch)
tree07edd1c112184f603ce73010973e5537d472c8d5 /array.c
parent852caed8a375ba761a786fc6c3d0da644422434f (diff)
* 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
Diffstat (limited to 'array.c')
-rw-r--r--array.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/array.c b/array.c
index 6e071e6..ef9007a 100644
--- a/array.c
+++ b/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 {