mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
5f60538245
commit
1e8461424c
Notes:
git
2020-06-29 11:07:03 +09:00
1 changed files with 4 additions and 5 deletions
9
hash.c
9
hash.c
|
@ -1288,15 +1288,14 @@ rb_hash_transient_heap_evacuate(VALUE hash, int promote)
|
|||
return;
|
||||
}
|
||||
HASH_ASSERT(old_tab != NULL);
|
||||
if (! promote) {
|
||||
new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
|
||||
if (new_tab == NULL) promote = true;
|
||||
}
|
||||
if (promote) {
|
||||
promote:
|
||||
new_tab = ruby_xmalloc(sizeof(ar_table));
|
||||
RHASH_UNSET_TRANSIENT_FLAG(hash);
|
||||
}
|
||||
else {
|
||||
new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
|
||||
if (new_tab == NULL) goto promote;
|
||||
}
|
||||
*new_tab = *old_tab;
|
||||
hash_ar_table_set(hash, new_tab);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue