summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-19 10:50:43 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commit8fc8912109cf7426afe6334850204744988c7a3d (patch)
treef75409def7e122b06400a41bdef96271f8b51c0e
parent08fc718e8c3a949c17d2b894a441ef183c28d8ac (diff)
exec_recursive: 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
-rw-r--r--thread.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index 6fdddde..3337735 100644
--- a/thread.c
+++ b/thread.c
@@ -5162,10 +5162,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
}
EC_POP_TAG();
if (!recursive_pop(p.list, p.obj, p.pairid)) {
- invalid:
- rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list "
- "for %+"PRIsVALUE" in %+"PRIsVALUE,
- sym, rb_thread_current());
+ goto invalid;
}
if (state != TAG_NONE) EC_JUMP_TAG(GET_EC(), state);
result = ret;
@@ -5173,6 +5170,11 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
}
*(volatile struct exec_recursive_params *)&p;
return result;
+
+ invalid:
+ rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list "
+ "for %+"PRIsVALUE" in %+"PRIsVALUE,
+ sym, rb_thread_current());
}
/*