From 603210060c08b2693bc9c597cf4200bf51efd362 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 6 Oct 2015 10:25:25 +0000 Subject: * vm_insnhelper.c (vm_call_method0): use switch() for visibilities (for readability). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ vm_insnhelper.c | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f47994812..fb22b6f325 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 6 19:24:38 2015 Koichi Sasada + + * vm_insnhelper.c (vm_call_method0): use switch() for visibilities + (for readability). + Tue Oct 6 19:23:58 2015 Koichi Sasada * proc.c (Init_Proc): Proc#call and others should be public. diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 532fb057d1..638ed6c336 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2114,12 +2114,12 @@ vm_call_method0(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info VM_ASSERT(callable_method_entry_p(cc->me)); if (cc->me != NULL) { - if (LIKELY(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PUBLIC)) { - VM_ASSERT(callable_method_entry_p(cc->me)); + switch (METHOD_ENTRY_VISI(cc->me)) { + case METHOD_VISI_PUBLIC: /* likely */ return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath); - } - else { - if (!(ci->flag & VM_CALL_FCALL) && (METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PRIVATE)) { + + case METHOD_VISI_PRIVATE: + if (!(ci->flag & VM_CALL_FCALL)) { enum method_missing_reason stat = MISSING_PRIVATE; if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL; @@ -2127,7 +2127,10 @@ vm_call_method0(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info CI_SET_FASTPATH(cc, vm_call_method_missing, 1); return vm_call_method_missing(th, cfp, calling, ci, cc); } - else if (!(ci->flag & VM_CALL_OPT_SEND) && (METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED)) { + return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath); + + case METHOD_VISI_PROTECTED: + if (!(ci->flag & VM_CALL_OPT_SEND)) { if (!rb_obj_is_kind_of(cfp->self, cc->me->defined_class)) { cc->aux.method_missing_reason = MISSING_PROTECTED; return vm_call_method_missing(th, cfp, calling, ci, cc); @@ -2137,16 +2140,15 @@ vm_call_method0(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info return vm_call_method_each_type(th, cfp, calling, ci, cc, FALSE); } } - else { - return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath); - } + return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath); + + default: + rb_bug("unreachable"); } } else { return vm_call_method_nome(th, cfp, calling, ci, cc); } - - rb_bug("vm_call_method: unreachable"); } static VALUE -- cgit v1.2.3