ruby-changes:31115
From: glass <ko1@a...>
Date: Tue, 8 Oct 2013 13:56:59 +0900 (JST)
Subject: [ruby-changes:31115] glass:r43194 (trunk): * array.c (rb_ary_uniq): use rb_hash_keys().
glass 2013-10-08 13:56:50 +0900 (Tue, 08 Oct 2013) New Revision: 43194 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43194 Log: * array.c (rb_ary_uniq): use rb_hash_keys(). * internal.h: define rb_hash_keys() as internal API. * hash.c (rb_hash_keys): ditto. Modified files: trunk/ChangeLog trunk/array.c trunk/hash.c trunk/internal.h Index: array.c =================================================================== --- array.c (revision 43193) +++ array.c (revision 43194) @@ -4130,13 +4130,7 @@ rb_ary_uniq(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4130 } else { hash = ary_make_hash(ary); - uniq = ary_new(rb_obj_class(ary), RHASH_SIZE(hash)); - for (i=0; i<RARRAY_LEN(ary); i++) { - st_data_t vv = (st_data_t)(v = rb_ary_elt(ary, i)); - if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) { - rb_ary_push(uniq, v); - } - } + uniq = rb_hash_keys(hash); } ary_recycle_hash(hash); Index: ChangeLog =================================================================== --- ChangeLog (revision 43193) +++ ChangeLog (revision 43194) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Oct 8 13:53:21 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_uniq): use rb_hash_keys(). + + * internal.h: define rb_hash_keys() as internal API. + + * hash.c (rb_hash_keys): ditto. + Tue Oct 8 10:56:39 2013 KOSAKI Motohiro <kosaki.motohiro@g...> * cont.c: disable FIBER_USE_NATIVE on GNU/Hurd because it doesn't Index: hash.c =================================================================== --- hash.c (revision 43193) +++ hash.c (revision 43194) @@ -1682,7 +1682,7 @@ keys_i(VALUE key, VALUE value, VALUE ary https://github.com/ruby/ruby/blob/trunk/hash.c#L1682 * */ -static VALUE +VALUE rb_hash_keys(VALUE hash) { VALUE ary; Index: internal.h =================================================================== --- internal.h (revision 43193) +++ internal.h (revision 43194) @@ -435,6 +435,7 @@ void rb_gc_writebarrier_remember_promote https://github.com/ruby/ruby/blob/trunk/internal.h#L435 /* hash.c */ struct st_table *rb_hash_tbl_raw(VALUE hash); #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h) +VALUE rb_hash_keys(VALUE hash); /* inits.c */ void rb_call_inits(void); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/