ruby-changes:29988
From: glass <ko1@a...>
Date: Thu, 18 Jul 2013 18:19:01 +0900 (JST)
Subject: [ruby-changes:29988] glass:r42040 (trunk): * hash.c (rb_hash_flatten): performance improvement by not using
glass 2013-07-18 18:18:50 +0900 (Thu, 18 Jul 2013) New Revision: 42040 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42040 Log: * hash.c (rb_hash_flatten): performance improvement by not using rb_hash_to_a() to avoid array creation with rb_assoc_new(). Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 42039) +++ array.c (revision 42040) @@ -4177,13 +4177,15 @@ rb_ary_count(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L4177 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 { Index: ChangeLog =================================================================== --- ChangeLog (revision 42039) +++ ChangeLog (revision 42040) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jul 18 18:14:36 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_count): iterate items appropriately. + [Bug #8654] + Thu Jul 18 17:35:41 2013 Masaki Matsushita <glass.saga@g...> * hash.c (rb_hash_flatten): performance improvement by not using -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/