aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-15 15:12:54 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commit1e8461424c10f8b22a926b2c6bc12dbf3eea4610 (patch)
tree94c8a089fe66d30a093fa59ee0051066dc080913 /hash.c
parent5f6053824551aec947a1c53d08975595aca1e513 (diff)
downloadruby-1e8461424c10f8b22a926b2c6bc12dbf3eea4610.tar.gz
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.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/hash.c b/hash.c
index acb237c46c..358b78580b 100644
--- a/hash.c
+++ b/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);
}