diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-09 07:17:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-09 07:17:02 +0000 |
commit | 921d6e269df182c3d9ab31f4bc084f5898d811e4 (patch) | |
tree | 53ee1b5732efd39e1825329fe1aeac66d7a886a1 /hash.c | |
parent | 865a326da921f2f5ed0def0605aec3a54981612d (diff) |
hash.c: hash_dup for rb_hash_to_h
* hash.c (rb_hash_to_h): share hash_dup to copy the contents and
the default value/proc only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -1881,14 +1881,8 @@ static VALUE rb_hash_to_h(VALUE hash) { if (rb_obj_class(hash) != rb_cHash) { - VALUE ret = rb_hash_new(); - if (!RHASH_EMPTY_P(hash)) - RHASH(ret)->ntbl = st_copy(RHASH(hash)->ntbl); - if (FL_TEST(hash, HASH_PROC_DEFAULT)) { - FL_SET(ret, HASH_PROC_DEFAULT); - } - RHASH_SET_IFNONE(ret, RHASH_IFNONE(hash)); - return ret; + const VALUE flags = RBASIC(hash)->flags; + hash = hash_dup(hash, rb_cHash, flags & HASH_PROC_DEFAULT); } return hash; } |