[前][次][番号順一覧][スレッド一覧]

ruby-changes:39980

From: ko1 <ko1@a...>
Date: Tue, 6 Oct 2015 19:25:30 +0900 (JST)
Subject: [ruby-changes:39980] ko1:r52061 (trunk): * vm_insnhelper.c (vm_call_method0): use switch() for visibilities

ko1	2015-10-06 19:25:25 +0900 (Tue, 06 Oct 2015)

  New Revision: 52061

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52061

  Log:
    * vm_insnhelper.c (vm_call_method0): use switch() for visibilities
      (for readability).

  Modified files:
    trunk/ChangeLog
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52060)
+++ ChangeLog	(revision 52061)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  6 19:24:38 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (vm_call_method0): use switch() for visibilities
+	  (for readability).
+
 Tue Oct  6 19:23:58 2015  Koichi Sasada  <ko1@a...>
 
 	* proc.c (Init_Proc): Proc#call and others should be public.
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 52060)
+++ vm_insnhelper.c	(revision 52061)
@@ -2114,12 +2114,12 @@ vm_call_method0(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2114
     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_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2127
 		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_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2140
 		    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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]