ruby-changes:62064
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:40 +0900 (JST)
Subject: [ruby-changes:62064] 1e9d58391c (master): rb_copy_generic_ivar: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=1e9d58391c From 1e9d58391c4f6b070d6713270a24181e7ec113a5 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, 22 Jun 2020 10:15:32 +0900 Subject: rb_copy_generic_ivar: 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/variable.c b/variable.c index 144f943..7477006 100644 --- a/variable.c +++ b/variable.c @@ -1494,12 +1494,7 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj) https://github.com/ruby/ruby/blob/trunk/variable.c#L1494 rb_check_frozen(clone); if (!FL_TEST(obj, FL_EXIVAR)) { - clear: - if (FL_TEST(clone, FL_EXIVAR)) { - rb_free_generic_ivar(clone); - FL_UNSET(clone, FL_EXIVAR); - } - return; + goto clear; } if (gen_ivtbl_get(obj, &ivtbl)) { struct givar_copy c; @@ -1526,6 +1521,13 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj) https://github.com/ruby/ruby/blob/trunk/variable.c#L1521 */ st_insert(generic_iv_tbl, (st_data_t)clone, (st_data_t)c.ivtbl); } + return; + + clear: + if (FL_TEST(clone, FL_EXIVAR)) { + rb_free_generic_ivar(clone); + FL_UNSET(clone, FL_EXIVAR); + } } void -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/