Skip to content

Commit 1e84614

Browse files
committed
rb_hash_transient_heap_evacuate: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
1 parent 5f60538 commit 1e84614

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

β€Žhash.cβ€Ž

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,15 +1288,14 @@ rb_hash_transient_heap_evacuate(VALUE hash, int promote)
12881288
return;
12891289
}
12901290
HASH_ASSERT(old_tab != NULL);
1291+
if (! promote) {
1292+
new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
1293+
if (new_tab == NULL) promote = true;
1294+
}
12911295
if (promote) {
1292-
promote:
12931296
new_tab = ruby_xmalloc(sizeof(ar_table));
12941297
RHASH_UNSET_TRANSIENT_FLAG(hash);
12951298
}
1296-
else {
1297-
new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
1298-
if (new_tab == NULL) goto promote;
1299-
}
13001299
*new_tab = *old_tab;
13011300
hash_ar_table_set(hash, new_tab);
13021301
}

0 commit comments

Comments
 (0)