diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-06 23:47:46 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-06 23:47:46 +0000 |
| commit | 86cc2435e490741b1d99d892862f64598b27954a (patch) | |
| tree | cdb53a860b84bbbc273e459689351fadc3f9ece4 /struct.c | |
| parent | 7271c065844647c29b11a8b8ee23c19432c90b87 (diff) | |
* struct.c (rb_struct_s_def): to_str should be called only once.
[ruby-core:16647]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
| -rw-r--r-- | struct.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -310,19 +310,14 @@ rb_struct_s_def(argc, argv, klass) ID id; rb_scan_args(argc, argv, "1*", &name, &rest); + if (!NIL_P(name) && SYMBOL_P(name)) { + rb_ary_unshift(rest, name); + name = Qnil; + } for (i=0; i<RARRAY(rest)->len; i++) { id = rb_to_id(RARRAY(rest)->ptr[i]); RARRAY(rest)->ptr[i] = ID2SYM(id); } - if (!NIL_P(name)) { - VALUE tmp = rb_check_string_type(name); - - if (NIL_P(tmp)) { - id = rb_to_id(name); - rb_ary_unshift(rest, ID2SYM(id)); - name = Qnil; - } - } st = make_struct(name, rest, klass); if (rb_block_given_p()) { rb_mod_module_eval(0, 0, st); |
