ruby-changes:41982
From: nobu <ko1@a...>
Date: Wed, 9 Mar 2016 16:17:07 +0900 (JST)
Subject: [ruby-changes:41982] nobu:r54056 (trunk): hash.c: hash_dup for rb_hash_to_h
nobu 2016-03-09 16:17:02 +0900 (Wed, 09 Mar 2016) New Revision: 54056 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54056 Log: 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. Modified files: trunk/hash.c Index: hash.c =================================================================== --- hash.c (revision 54055) +++ hash.c (revision 54056) @@ -1881,14 +1881,8 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/hash.c#L1881 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/