summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-10 16:28:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-10 16:28:56 +0000
commitb28ce966c75b1ac243ca8a43cdd7e51d856828c5 (patch)
tree29bc33a79020c953b5483e1b16225ca8df315e1a /hash.c
parentd4f37a5532b06462e958281fe51ed3a3c8f18b67 (diff)
st.c: revert st_keys
* st.c: revert st_keys() at r43238. VALUE cannot be in st.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 2cedeef..83d1799 100644
--- a/hash.c
+++ b/hash.c
@@ -1663,6 +1663,13 @@ rb_hash_to_h(VALUE hash)
return hash;
}
+static int
+keys_i(VALUE key, VALUE value, VALUE ary)
+{
+ rb_ary_push(ary, key);
+ return ST_CONTINUE;
+}
+
/*
* call-seq:
* hsh.keys -> array
@@ -1678,10 +1685,12 @@ rb_hash_to_h(VALUE hash)
VALUE
rb_hash_keys(VALUE hash)
{
- st_table *table = RHASH(hash)->ntbl;
+ VALUE ary;
+
+ ary = rb_ary_new_capa(RHASH_SIZE(hash));
+ rb_hash_foreach(hash, keys_i, ary);
- if (!table) return rb_ary_new();
- return st_keys(table);
+ return ary;
}
static int