summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
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 6e071e6f17..ef9007ae0d 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 {