ruby-changes:31470
From: glass <ko1@a...>
Date: Wed, 6 Nov 2013 10:40:02 +0900 (JST)
Subject: [ruby-changes:31470] glass:r43549 (trunk): * array.c (rb_ary_and): defer hash creation and some refactoring.
glass 2013-11-06 10:39:55 +0900 (Wed, 06 Nov 2013) New Revision: 43549 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43549 Log: * array.c (rb_ary_and): defer hash creation and some refactoring. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 43548) +++ array.c (revision 43549) @@ -4009,20 +4009,20 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L4009 rb_ary_and(VALUE ary1, VALUE ary2) { VALUE hash, ary3, v; + st_table *table; st_data_t vv; long i; ary2 = to_ary(ary2); - ary3 = rb_ary_new2(RARRAY_LEN(ary1) < RARRAY_LEN(ary2) ? - RARRAY_LEN(ary1) : RARRAY_LEN(ary2)); + ary3 = rb_ary_new(); + if (RARRAY_LEN(ary2) == 0) return ary3; hash = ary_make_hash(ary2); - - if (RHASH_EMPTY_P(hash)) - return ary3; + table = rb_hash_tbl_raw(hash); for (i=0; i<RARRAY_LEN(ary1); i++) { - vv = (st_data_t)(v = rb_ary_elt(ary1, i)); - if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) { + v = RARRAY_AREF(ary1, i); + vv = (st_data_t)v; + if (st_delete(table, &vv, 0)) { rb_ary_push(ary3, v); } } Index: ChangeLog =================================================================== --- ChangeLog (revision 43548) +++ ChangeLog (revision 43549) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Nov 6 10:37:07 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_and): defer hash creation and some refactoring. + Wed Nov 6 09:14:31 2013 Koichi Sasada <ko1@a...> * benchmark/bm_vm1_gc_short_lived.rb: added. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/