summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2014-04-20 09:01:04 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2014-04-20 09:01:04 +0000
commit6ecf40e1fa1b2c55f63d0ccb46bce2fca73b40ad (patch)
tree368a0326bcf36bc7e06cbbe7a1d55b752afd86ba /array.c
parentcb3ea602294b5038b5f7ac21d3875a2b52342956 (diff)
parent680d09b61ea7d850e27944311723a40c596e5d95 (diff)
downloadruby-baserock/ps/proto-web-system.tar.gz
Merge commit '680d09' into baserock/ps/proto-web-systembaserock/ps/proto-web-system
Diffstat (limited to 'array.c')
-rw-r--r--array.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/array.c b/array.c
index e427cb3320..73f7669f94 100644
--- a/array.c
+++ b/array.c
@@ -3692,27 +3692,28 @@ rb_ary_compact(VALUE ary)
static VALUE
rb_ary_count(int argc, VALUE *argv, VALUE ary)
{
- long n = 0;
+ long i, n = 0;
if (argc == 0) {
- VALUE *p, *pend;
+ 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_PTR(ary)[i];
+ if (RTEST(rb_yield(v))) n++;
}
}
else {
- VALUE obj, *p, *pend;
+ VALUE obj;
rb_scan_args(argc, argv, "1", &obj);
if (rb_block_given_p()) {
rb_warn("given block not used");
}
- for (p = RARRAY_PTR(ary), pend = p + RARRAY_LEN(ary); p < pend; p++) {
- if (rb_equal(*p, obj)) n++;
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ if (rb_equal(RARRAY_PTR(ary)[i], obj)) n++;
}
}