@@ -1199,44 +1199,28 @@ static ar_table*
11991199ar_copy (VALUE hash1 , VALUE hash2 )
12001200{
12011201 ar_table * old_tab = RHASH_AR_TABLE (hash2 );
1202+ ar_table * new_tab = RHASH_AR_TABLE (hash1 );
12021203
1203- if (old_tab != NULL ) {
1204- ar_table * new_tab = RHASH_AR_TABLE (hash1 );
1205- if (new_tab == NULL ) {
1206- new_tab = (ar_table * ) rb_transient_heap_alloc (hash1 , sizeof (ar_table ));
1207- if (new_tab != NULL ) {
1208- RHASH_SET_TRANSIENT_FLAG (hash1 );
1209- }
1210- else {
1211- RHASH_UNSET_TRANSIENT_FLAG (hash1 );
1212- new_tab = (ar_table * )ruby_xmalloc (sizeof (ar_table ));
1213- }
1204+ if (new_tab == NULL ) {
1205+ new_tab = (ar_table * ) rb_transient_heap_alloc (hash1 , sizeof (ar_table ));
1206+ if (new_tab != NULL ) {
1207+ RHASH_SET_TRANSIENT_FLAG (hash1 );
12141208 }
1215- * new_tab = * old_tab ;
1216- RHASH (hash1 )-> ar_hint .word = RHASH (hash2 )-> ar_hint .word ;
1217- RHASH_AR_TABLE_BOUND_SET (hash1 , RHASH_AR_TABLE_BOUND (hash2 ));
1218- RHASH_AR_TABLE_SIZE_SET (hash1 , RHASH_AR_TABLE_SIZE (hash2 ));
1219- hash_ar_table_set (hash1 , new_tab );
1220-
1221- rb_gc_writebarrier_remember (hash1 );
1222- return new_tab ;
1223- }
1224- else {
1225- RHASH_AR_TABLE_BOUND_SET (hash1 , RHASH_AR_TABLE_BOUND (hash2 ));
1226- RHASH_AR_TABLE_SIZE_SET (hash1 , RHASH_AR_TABLE_SIZE (hash2 ));
1227-
1228- if (RHASH_TRANSIENT_P (hash1 )) {
1209+ else {
12291210 RHASH_UNSET_TRANSIENT_FLAG (hash1 );
1211+ new_tab = (ar_table * )ruby_xmalloc (sizeof (ar_table ));
12301212 }
1231- else if (RHASH_AR_TABLE (hash1 )) {
1232- ruby_xfree (RHASH_AR_TABLE (hash1 ));
1233- }
1213+ }
12341214
1235- hash_ar_table_set (hash1 , NULL );
1215+ * new_tab = * old_tab ;
1216+ RHASH (hash1 )-> ar_hint .word = RHASH (hash2 )-> ar_hint .word ;
1217+ RHASH_AR_TABLE_BOUND_SET (hash1 , RHASH_AR_TABLE_BOUND (hash2 ));
1218+ RHASH_AR_TABLE_SIZE_SET (hash1 , RHASH_AR_TABLE_SIZE (hash2 ));
1219+ hash_ar_table_set (hash1 , new_tab );
12361220
1237- rb_gc_writebarrier_remember (hash1 );
1238- return old_tab ;
1239- }
1221+ rb_gc_writebarrier_remember (hash1 );
1222+
1223+ return new_tab ;
12401224}
12411225
12421226static void
0 commit comments