summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-18 00:24:00 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-18 00:24:00 +0000
commita34a3c2caae4c1fbd9b4a0fa7194e0edfbad6bbe (patch)
treee6ecfaf77e13023217c22fcb83bbda11b2ebccc1 /hash.c
parentbff930ccf476e1a7e01720e2fd4f6c09d226a56f (diff)
* hash.c (initialize_copy): duping should rehash the hash.
* test/ruby/test_hash.rb: added a test to ensure rehash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 5172e13b57..bf9dbd5467 100644
--- a/hash.c
+++ b/hash.c
@@ -1187,8 +1187,11 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2)
{
Check_Type(hash2, T_HASH);
- if (!RHASH_EMPTY_P(hash2))
+ if (!RHASH_EMPTY_P(hash2)) {
RHASH(hash)->ntbl = st_copy(RHASH(hash2)->ntbl);
+ rb_hash_rehash(hash);
+ }
+
if (FL_TEST(hash2, HASH_PROC_DEFAULT)) {
FL_SET(hash, HASH_PROC_DEFAULT);
}