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

ruby-changes:38934

From: nobu <ko1@a...>
Date: Wed, 24 Jun 2015 17:32:09 +0900 (JST)
Subject: [ruby-changes:38934] nobu:r51015 (trunk): vm_method.c: use the current visibility

nobu	2015-06-24 17:31:43 +0900 (Wed, 24 Jun 2015)

  New Revision: 51015

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

  Log:
    vm_method.c: use the current visibility
    
    * vm_method.c (rb_attr): simply use the current visibility,
      instead of tests for each visibilities.

  Modified files:
    trunk/vm_method.c
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 51014)
+++ vm_method.c	(revision 51015)
@@ -912,17 +912,17 @@ rb_method_boundp(VALUE klass, ID id, int https://github.com/ruby/ruby/blob/trunk/vm_method.c#L912
     return 0;
 }
 
-static int
-rb_scope_visibility_test(rb_method_visibility_t visi)
+static rb_method_visibility_t
+rb_scope_visibility_get(void)
 {
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
 
     if (!vm_env_cref_by_cref(cfp->ep)) {
-	return METHOD_VISI_PUBLIC == visi;
+	return METHOD_VISI_PUBLIC;
     }
     else {
-	return CREF_SCOPE_VISI(rb_vm_cref())->method_visi == visi;
+	return CREF_SCOPE_VISI(rb_vm_cref())->method_visi;
     }
 }
 
@@ -958,17 +958,19 @@ rb_attr(VALUE klass, ID id, int read, in https://github.com/ruby/ruby/blob/trunk/vm_method.c#L958
 	visi = METHOD_VISI_PUBLIC;
     }
     else {
-	if (rb_scope_visibility_test(METHOD_VISI_PRIVATE)) {
-	    visi = METHOD_VISI_PRIVATE;
+	switch (rb_scope_visibility_get()) {
+	  case METHOD_VISI_PRIVATE:
 	    if (rb_scope_module_func_check()) {
 		rb_warning("attribute accessor as module_function");
 	    }
-	}
-	else if (rb_scope_visibility_test(METHOD_VISI_PROTECTED)) {
+	    visi = METHOD_VISI_PRIVATE;
+	    break;
+	  case METHOD_VISI_PROTECTED:
 	    visi = METHOD_VISI_PROTECTED;
-	}
-	else {
+	    break;
+	  default:
 	    visi = METHOD_VISI_PUBLIC;
+	    break;
 	}
     }
 

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

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