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

ruby-changes:38933

From: nobu <ko1@a...>
Date: Wed, 24 Jun 2015 17:29:35 +0900 (JST)
Subject: [ruby-changes:38933] nobu:r51014 (trunk): vm_method.c: remove redundant check

nobu	2015-06-24 17:29:03 +0900 (Wed, 24 Jun 2015)

  New Revision: 51014

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

  Log:
    vm_method.c: remove redundant check
    
    * vm_method.c (rb_attr): remove redundant check.  attribute names
      given in ruby level should be checked before calling this
      function.

  Modified files:
    trunk/object.c
    trunk/vm_method.c
Index: object.c
===================================================================
--- object.c	(revision 51013)
+++ object.c	(revision 51014)
@@ -1924,12 +1924,6 @@ check_setter_id(VALUE name, int (*valid_ https://github.com/ruby/ruby/blob/trunk/object.c#L1924
 }
 
 static int
-rb_is_attr_id(ID id)
-{
-    return rb_is_local_id(id) || rb_is_const_id(id);
-}
-
-static int
 rb_is_attr_name(VALUE name)
 {
     return rb_is_local_name(name) || rb_is_const_name(name);
@@ -1949,15 +1943,6 @@ id_for_attr(VALUE name) https://github.com/ruby/ruby/blob/trunk/object.c#L1943
     return id_for_setter(name, attr, invalid_attribute_name);
 }
 
-ID
-rb_check_attr_id(ID id)
-{
-    if (!rb_is_attr_id(id)) {
-	rb_name_error_str(id, invalid_attribute_name, QUOTE_ID(id));
-    }
-    return id;
-}
-
 /*
  *  call-seq:
  *     attr_reader(symbol, ...)  -> nil
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 51013)
+++ vm_method.c	(revision 51014)
@@ -912,8 +912,6 @@ rb_method_boundp(VALUE klass, ID id, int https://github.com/ruby/ruby/blob/trunk/vm_method.c#L912
     return 0;
 }
 
-extern ID rb_check_attr_id(ID id);
-
 static int
 rb_scope_visibility_test(rb_method_visibility_t visi)
 {
@@ -953,8 +951,7 @@ rb_scope_module_func_set(void) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L951
 void
 rb_attr(VALUE klass, ID id, int read, int write, int ex)
 {
-    VALUE attriv;
-    VALUE aname;
+    ID attriv;
     rb_method_visibility_t visi;
 
     if (!ex) {
@@ -975,11 +972,7 @@ rb_attr(VALUE klass, ID id, int read, in https://github.com/ruby/ruby/blob/trunk/vm_method.c#L972
 	}
     }
 
-    aname = rb_id2str(rb_check_attr_id(id));
-    if (NIL_P(aname)) {
-	rb_raise(rb_eArgError, "argument needs to be symbol or string");
-    }
-    attriv = (VALUE)rb_intern_str(rb_sprintf("@%"PRIsVALUE, aname));
+    attriv = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id)));
     if (read) {
 	rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, visi);
     }

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

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