1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

object.c: no longer copy tables of classes/modules

* object.c (init_copy): no longer copy tables of classes/modules,
  since r45874 rb_mod_init_copy() does it instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-05-08 05:45:00 +00:00
parent 7c072b35d1
commit 16b8aadc75

View file

@ -265,8 +265,7 @@ init_copy(VALUE dest, VALUE obj)
RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT); RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT);
rb_copy_generic_ivar(dest, obj); rb_copy_generic_ivar(dest, obj);
rb_gc_copy_finalizer(dest, obj); rb_gc_copy_finalizer(dest, obj);
switch (TYPE(obj)) { if (RB_TYPE_P(obj, T_OBJECT)) {
case T_OBJECT:
if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) { if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_IVPTR(dest)) {
xfree(ROBJECT_IVPTR(dest)); xfree(ROBJECT_IVPTR(dest));
ROBJECT(dest)->as.heap.ivptr = 0; ROBJECT(dest)->as.heap.ivptr = 0;
@ -286,21 +285,6 @@ init_copy(VALUE dest, VALUE obj)
ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl; ROBJECT(dest)->as.heap.iv_index_tbl = ROBJECT(obj)->as.heap.iv_index_tbl;
RBASIC(dest)->flags &= ~ROBJECT_EMBED; RBASIC(dest)->flags &= ~ROBJECT_EMBED;
} }
break;
case T_CLASS:
case T_MODULE:
if (RCLASS_IV_TBL(dest)) {
st_free_table(RCLASS_IV_TBL(dest));
RCLASS_IV_TBL(dest) = 0;
}
if (RCLASS_CONST_TBL(dest)) {
rb_free_const_table(RCLASS_CONST_TBL(dest));
RCLASS_CONST_TBL(dest) = 0;
}
if (RCLASS_IV_TBL(obj)) {
RCLASS_IV_TBL(dest) = rb_st_copy(dest, RCLASS_IV_TBL(obj));
}
break;
} }
} }