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

ruby-changes:4813

From: ko1@a...
Date: Wed, 7 May 2008 08:47:59 +0900 (JST)
Subject: [ruby-changes:4813] matz - Ruby:r16307 (ruby_1_8): * struct.c (rb_struct_s_def): to_str should be called only once.

matz	2008-05-07 08:47:46 +0900 (Wed, 07 May 2008)

  New Revision: 16307

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/struct.c

  Log:
    * struct.c (rb_struct_s_def): to_str should be called only once.
      [ruby-core:16647]

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16307&r2=16306&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/struct.c?r1=16307&r2=16306&diff_format=u

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 16306)
+++ ruby_1_8/ChangeLog	(revision 16307)
@@ -1,3 +1,8 @@
+Wed May  7 08:46:44 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* struct.c (rb_struct_s_def): to_str should be called only once.
+	  [ruby-core:16647]
+
 Wed May  7 00:54:25 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* ext/zlib/zlib.c (gzreader_gets): may cause infinite loop.
Index: ruby_1_8/struct.c
===================================================================
--- ruby_1_8/struct.c	(revision 16306)
+++ ruby_1_8/struct.c	(revision 16307)
@@ -310,19 +310,14 @@
     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);

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

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