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

ruby-changes:34609

From: nobu <ko1@a...>
Date: Fri, 4 Jul 2014 16:16:35 +0900 (JST)
Subject: [ruby-changes:34609] nobu:r46690 (trunk): parse.y: use rb_fstring_new

nobu	2014-07-04 16:16:21 +0900 (Fri, 04 Jul 2014)

  New Revision: 46690

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46690

  Log:
    parse.y: use rb_fstring_new
    
    * parse.y (rb_id2str): use rb_fstring_new() instead of rb_fstring()
      with a new string instance.

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 46689)
+++ parse.y	(revision 46690)
@@ -10144,6 +10144,8 @@ static const struct { https://github.com/ruby/ruby/blob/trunk/parse.y#L10144
 };
 
 #define op_tbl_count numberof(op_tbl)
+STATIC_ASSERT(op_tbl_name_size, sizeof(op_tbl[0].name) == 3);
+#define op_tbl_len(i) (!op_tbl[i].name[1] ? 1 : !op_tbl[i].name[2] ? 2 : 3)
 
 static struct symbols {
     ID last_id;
@@ -10800,9 +10802,7 @@ rb_id2str(ID id) https://github.com/ruby/ruby/blob/trunk/parse.y#L10802
 		char name[2];
 		name[0] = (char)id;
 		name[1] = 0;
-		str = rb_usascii_str_new(name, 1);
-		OBJ_FREEZE(str);
-		str = rb_fstring(str);
+		str = rb_fstring_new(name, 1);
 		global_symbols.op_sym[i] = str;
 		global_symbols.minor_marked = 0;
 	    }
@@ -10812,9 +10812,8 @@ rb_id2str(ID id) https://github.com/ruby/ruby/blob/trunk/parse.y#L10812
 	    if (op_tbl[i].token == id) {
 		VALUE str = global_symbols.op_sym[i];
 		if (!str) {
-		    str = rb_usascii_str_new2(op_tbl[i].name);
-		    OBJ_FREEZE(str);
-		    str = rb_fstring(str);
+		    const char *name = op_tbl[i].name;
+		    str = rb_fstring_new(name, op_tbl_len(i));
 		    global_symbols.op_sym[i] = str;
 		    global_symbols.minor_marked = 0;
 		}

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

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