ruby-changes:62003
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:07 +0900 (JST)
Subject: [ruby-changes:62003] 1e8461424c (master): rb_hash_transient_heap_evacuate: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=1e8461424c From 1e8461424c10f8b22a926b2c6bc12dbf3eea4610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Mon, 15 Jun 2020 15:12:54 +0900 Subject: 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. diff --git a/hash.c b/hash.c index acb237c..358b785 100644 --- a/hash.c +++ b/hash.c @@ -1288,15 +1288,14 @@ rb_hash_transient_heap_evacuate(VALUE hash, int promote) https://github.com/ruby/ruby/blob/trunk/hash.c#L1288 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); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/