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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43b5e3d7cd
commit
d92b0dc58a
15
object.c
15
object.c
@ -1923,12 +1923,6 @@ check_setter_id(VALUE name, int (*valid_sym_p)(VALUE), int (*valid_name_p)(VALUE
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
rb_is_attr_id(ID id)
|
|
||||||
{
|
|
||||||
return rb_is_local_id(id) || rb_is_const_id(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_is_attr_name(VALUE name)
|
rb_is_attr_name(VALUE name)
|
||||||
{
|
{
|
||||||
@ -1949,15 +1943,6 @@ id_for_attr(VALUE name)
|
|||||||
return id_for_setter(name, attr, invalid_attribute_name);
|
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:
|
* call-seq:
|
||||||
* attr_reader(symbol, ...) -> nil
|
* attr_reader(symbol, ...) -> nil
|
||||||
|
11
vm_method.c
11
vm_method.c
@ -912,8 +912,6 @@ rb_method_boundp(VALUE klass, ID id, int ex)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern ID rb_check_attr_id(ID id);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_scope_visibility_test(rb_method_visibility_t visi)
|
rb_scope_visibility_test(rb_method_visibility_t visi)
|
||||||
{
|
{
|
||||||
@ -953,8 +951,7 @@ rb_scope_module_func_set(void)
|
|||||||
void
|
void
|
||||||
rb_attr(VALUE klass, ID id, int read, int write, int ex)
|
rb_attr(VALUE klass, ID id, int read, int write, int ex)
|
||||||
{
|
{
|
||||||
VALUE attriv;
|
ID attriv;
|
||||||
VALUE aname;
|
|
||||||
rb_method_visibility_t visi;
|
rb_method_visibility_t visi;
|
||||||
|
|
||||||
if (!ex) {
|
if (!ex) {
|
||||||
@ -975,11 +972,7 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aname = rb_id2str(rb_check_attr_id(id));
|
attriv = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(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));
|
|
||||||
if (read) {
|
if (read) {
|
||||||
rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, visi);
|
rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, visi);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user