From 5f4e78423337662d0fc6cccf63a0fc8835715fae Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 10 Aug 2021 14:46:17 -0700 Subject: [PATCH] Avoid unnecessary conditional All frames should be either iseq frames or cfunc frames. Use a VM assert instead of a conditional to check for a cfunc frame if the current frame is not an iseq frame. --- vm_backtrace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm_backtrace.c b/vm_backtrace.c index 27e108af61..8cb4881e15 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -648,7 +648,8 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram } } } - else if (RUBYVM_CFUNC_FRAME_P(cfp)) { + else { + VM_ASSERT(RUBYVM_CFUNC_FRAME_P(cfp)); if (start_frame > 0) { start_frame--; } @@ -917,7 +918,8 @@ backtrace_each(const rb_execution_context_t *ec, iter_iseq(arg, cfp); } } - else if (RUBYVM_CFUNC_FRAME_P(cfp)) { + else { + VM_ASSERT(RUBYVM_CFUNC_FRAME_P(cfp)); const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp); ID mid = me->def->original_id;