@@ -339,17 +339,16 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
339339 shape_id_t dest_shape_id = src_shape_id ;
340340 shape_id_t initial_shape_id = RBASIC_SHAPE_ID (dest );
341341
342- if (RSHAPE (initial_shape_id )-> heap_index != RSHAPE (src_shape_id )-> heap_index || !rb_shape_canonical_p (src_shape_id )) {
343- RUBY_ASSERT (RSHAPE (initial_shape_id )-> type == SHAPE_T_OBJECT );
342+ RUBY_ASSERT (RSHAPE (initial_shape_id )-> type == SHAPE_ROOT );
344343
345- dest_shape_id = rb_shape_rebuild (initial_shape_id , src_shape_id );
346- if (UNLIKELY (rb_shape_too_complex_p (dest_shape_id ))) {
347- st_table * table = rb_st_init_numtable_with_size (src_num_ivs );
348- rb_obj_copy_ivs_to_hash_table (obj , table );
349- rb_obj_init_too_complex (dest , table );
344+ dest_shape_id = rb_shape_rebuild (initial_shape_id , src_shape_id );
350345
351- return ;
352- }
346+ if (UNLIKELY (rb_shape_too_complex_p (dest_shape_id ))) {
347+ st_table * table = rb_st_init_numtable_with_size (src_num_ivs );
348+ rb_obj_copy_ivs_to_hash_table (obj , table );
349+ rb_obj_init_too_complex (dest , table );
350+
351+ return ;
353352 }
354353
355354 VALUE * src_buf = ROBJECT_FIELDS (obj );
@@ -358,14 +357,13 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
358357 attr_index_t initial_capa = RSHAPE_CAPACITY (initial_shape_id );
359358 attr_index_t dest_capa = RSHAPE_CAPACITY (dest_shape_id );
360359
361- RUBY_ASSERT (src_num_ivs <= initial_capa );
362360 if (initial_capa < dest_capa ) {
363- rb_ensure_iv_list_size (dest , initial_capa , dest_capa );
361+ rb_ensure_iv_list_size (dest , 0 , dest_capa );
364362 dest_buf = ROBJECT_FIELDS (dest );
365363 }
366364
367365 rb_shape_copy_fields (dest , dest_buf , dest_shape_id , obj , src_buf , src_shape_id );
368- rb_obj_set_shape_id (dest , dest_shape_id );
366+ RBASIC_SET_SHAPE_ID (dest , dest_shape_id );
369367}
370368
371369static void
0 commit comments