mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
use RARRAY_AREF().
* struct.c (setup_struct): no need to use Array raw ptr here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
509d8f81a6
commit
f8f77d8423
1 changed files with 3 additions and 4 deletions
7
struct.c
7
struct.c
|
@ -313,7 +313,6 @@ rb_struct_s_inspect(VALUE klass)
|
|||
static VALUE
|
||||
setup_struct(VALUE nstr, VALUE members)
|
||||
{
|
||||
const VALUE *ptr_members;
|
||||
long i, len;
|
||||
|
||||
members = struct_set_members(nstr, members);
|
||||
|
@ -323,17 +322,17 @@ setup_struct(VALUE nstr, VALUE members)
|
|||
rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
|
||||
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
|
||||
rb_define_singleton_method(nstr, "inspect", rb_struct_s_inspect, 0);
|
||||
ptr_members = RARRAY_CONST_PTR(members);
|
||||
len = RARRAY_LEN(members);
|
||||
for (i=0; i< len; i++) {
|
||||
ID id = SYM2ID(ptr_members[i]);
|
||||
VALUE sym = RARRAY_AREF(members, i);
|
||||
ID id = SYM2ID(sym);
|
||||
VALUE off = LONG2NUM(i);
|
||||
|
||||
if (i < N_REF_FUNC) {
|
||||
rb_define_method_id(nstr, id, ref_func[i], 0);
|
||||
}
|
||||
else {
|
||||
define_aref_method(nstr, ptr_members[i], off);
|
||||
define_aref_method(nstr, sym, off);
|
||||
}
|
||||
define_aset_method(nstr, ID2SYM(rb_id_attrset(id)), off);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue