struct.c: hide member names

* struct.c (rb_struct_define_without_accessor, rb_struct_define),
  (rb_struct_s_def): hide member names array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-04-13 01:20:39 +00:00
parent 5e5690781c
commit a69c74be72
2 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,7 @@
Sat Apr 13 10:20:32 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Apr 13 10:20:37 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* struct.c (rb_struct_define_without_accessor, rb_struct_define),
(rb_struct_s_def): hide member names array.
* struct.c (anonymous_struct, new_struct, setup_struct): split * struct.c (anonymous_struct, new_struct, setup_struct): split
make_struct() for each purpose. make_struct() for each purpose.

View File

@ -243,7 +243,7 @@ rb_struct_define_without_accessor(const char *class_name, VALUE super, rb_alloc_
VALUE members; VALUE members;
char *name; char *name;
members = rb_ary_new2(0); members = rb_ary_tmp_new(0);
va_start(ar, alloc); va_start(ar, alloc);
while ((name = va_arg(ar, char*)) != NULL) { while ((name = va_arg(ar, char*)) != NULL) {
rb_ary_push(members, ID2SYM(rb_intern(name))); rb_ary_push(members, ID2SYM(rb_intern(name)));
@ -275,7 +275,7 @@ rb_struct_define(const char *name, ...)
VALUE st, ary; VALUE st, ary;
char *mem; char *mem;
ary = rb_ary_new(); ary = rb_ary_tmp_new(0);
va_start(ar, name); va_start(ar, name);
while ((mem = va_arg(ar, char*)) != 0) { while ((mem = va_arg(ar, char*)) != 0) {
@ -351,7 +351,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
--argc; --argc;
++argv; ++argv;
} }
rest = rb_ary_new2(argc); rest = rb_ary_tmp_new(argc);
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
id = rb_to_id(argv[i]); id = rb_to_id(argv[i]);
RARRAY_PTR(rest)[i] = ID2SYM(id); RARRAY_PTR(rest)[i] = ID2SYM(id);