method
initialize_copy
v2_5_5 -
Show latest stable
- Class:
Hash
initialize_copy(p1)public
No documentation available.
static VALUE
rb_hash_initialize_copy(VALUE hash, VALUE hash2)
{
st_table *ntbl;
rb_hash_modify_check(hash);
hash2 = to_hash(hash2);
Check_Type(hash2, T_HASH);
if (hash == hash2) return hash;
ntbl = RHASH(hash)->ntbl;
if (RHASH(hash2)->ntbl) {
if (ntbl) st_free_table(ntbl);
RHASH(hash)->ntbl = st_copy(RHASH(hash2)->ntbl);
if (RHASH(hash)->ntbl->num_entries)
rb_hash_rehash(hash);
}
else if (ntbl) {
st_clear(ntbl);
}
COPY_DEFAULT(hash, hash2);
return hash;
}