summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--array.c8
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ab67c8a..ed5850d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
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 {