diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-22 10:15:32 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 1e9d58391c4f6b070d6713270a24181e7ec113a5 (patch) | |
tree | 85dcb5196d0c091714a10980d033ffe99b226e12 /variable.c | |
parent | fc45a061b9c317bfe1f7a9b726e7056db93950c8 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/variable.c b/variable.c index 144f943618..7477006370 100644 --- a/variable.c +++ b/variable.c @@ -1494,12 +1494,7 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj) 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) */ 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 |