summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--array.c8
-rw-r--r--hash.c2
-rw-r--r--internal.h1
4 files changed, 11 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fb5ac6e0b..e46ff49664 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/array.c b/array.c
index 76289f41f6..e94eff5b0d 100644
--- a/array.c
+++ b/array.c
@@ -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);
diff --git a/hash.c b/hash.c
index 9eca54876f..d65a698fc2 100644
--- a/hash.c
+++ b/hash.c
@@ -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);