aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-06 10:25:25 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-06 10:25:25 +0000
commit52cddd29a2c6ae4b71682ba3459d14e612400eb0 (patch)
treebbf192f3286cc7cbf4609802574b547cd6bd1d7d /vm_insnhelper.c
parente095f989e7a8cd6b7be17737870e92b762ce1be0 (diff)
downloadruby-52cddd29a2c6ae4b71682ba3459d14e612400eb0.tar.gz
* 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
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c24
1 files changed, 13 insertions, 11 deletions
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