aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index dd78d2d8e1..4a3f2ff536 100644
--- a/hash.c
+++ b/hash.c
@@ -1558,10 +1558,8 @@ rb_hash_new_with_size(st_index_t size)
}
static VALUE
-hash_dup(VALUE hash, VALUE klass, VALUE flags)
+hash_copy(VALUE ret, VALUE hash)
{
- VALUE ret = hash_alloc_flags(klass, flags,
- RHASH_IFNONE(hash));
if (!RHASH_EMPTY_P(hash)) {
if (RHASH_AR_TABLE_P(hash))
ar_copy(ret, hash);
@@ -1571,6 +1569,13 @@ hash_dup(VALUE hash, VALUE klass, VALUE flags)
return ret;
}
+static VALUE
+hash_dup(VALUE hash, VALUE klass, VALUE flags)
+{
+ return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash)),
+ hash);
+}
+
VALUE
rb_hash_dup(VALUE hash)
{
@@ -3205,7 +3210,7 @@ rb_hash_transform_values(VALUE hash)
VALUE result;
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
- result = hash_dup(hash, rb_cHash, 0);
+ result = hash_copy(hash_alloc(rb_cHash), hash);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);