diff options
author | 卜部昌平 <[email protected]> | 2020-06-22 10:57:01 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2020-06-29 11:05:41 +0900 |
commit | f12efec2c2698fb1ea775ce3d260a35628303833 (patch) | |
tree | c385b349f4f14ae9b0a262b34d694d18f392fb0f /vm.c | |
parent | b95b249784d51697f9f890d6f2a4fba5be08e342 (diff) |
vm_exec_handle_exception: 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 'vm.c')
-rw-r--r-- | vm.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -2083,10 +2083,16 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, } } } - else if (state == TAG_BREAK && !escape_cfp) { - type = CATCH_TYPE_BREAK; + else if ((state == TAG_BREAK && !escape_cfp) || + (state == TAG_REDO) || + (state == TAG_NEXT)) { + type = (const enum catch_type[TAG_MASK]) { + [TAG_BREAK] = CATCH_TYPE_BREAK, + [TAG_NEXT] = CATCH_TYPE_NEXT, + [TAG_REDO] = CATCH_TYPE_REDO, + /* otherwise = dontcare */ + }[state]; - search_restart_point: ct = cfp->iseq->body->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); @@ -2116,14 +2122,6 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, } } } - else if (state == TAG_REDO) { - type = CATCH_TYPE_REDO; - goto search_restart_point; - } - else if (state == TAG_NEXT) { - type = CATCH_TYPE_NEXT; - goto search_restart_point; - } else { ct = cfp->iseq->body->catch_table; if (ct) for (i = 0; i < ct->size; i++) { |