diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | array.c | 8 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | internal.h | 1 |
4 files changed, 11 insertions, 8 deletions
@@ -1,3 +1,11 @@ +Tue Oct 8 13:53:21 2013 Masaki Matsushita <glass.saga@gmail.com> + + * 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@gmail.com> * cont.c: disable FIBER_USE_NATIVE on GNU/Hurd because it doesn't @@ -4130,13 +4130,7 @@ rb_ary_uniq(VALUE ary) } 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); @@ -1682,7 +1682,7 @@ keys_i(VALUE key, VALUE value, VALUE ary) * */ -static VALUE +VALUE rb_hash_keys(VALUE hash) { VALUE ary; diff --git a/internal.h b/internal.h index f26a63dbf6..ad710d08d8 100644 --- a/internal.h +++ b/internal.h @@ -435,6 +435,7 @@ void rb_gc_writebarrier_remember_promoted(VALUE obj); /* 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); |