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

ruby-changes:33353

From: nobu <ko1@a...>
Date: Wed, 26 Mar 2014 15:34:46 +0900 (JST)
Subject: [ruby-changes:33353] nobu:r45431 (trunk): parse.y: dup iff needed

nobu	2014-03-26 15:34:33 +0900 (Wed, 26 Mar 2014)

  New Revision: 45431

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

  Log:
    parse.y: dup iff needed
    
    * parse.y (rb_str_dynamic_intern): dup the given string only if
      needed.

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 45430)
+++ parse.y	(revision 45431)
@@ -10671,7 +10671,6 @@ rb_str_dynamic_intern(VALUE s) https://github.com/ruby/ruby/blob/trunk/parse.y#L10671
 {
 #if USE_SYMBOL_GC
     VALUE str = RB_GC_GUARD(s);
-    VALUE dup;
     rb_encoding *enc, *ascii;
     VALUE dsym;
     ID id, type;
@@ -10680,18 +10679,18 @@ rb_str_dynamic_intern(VALUE s) https://github.com/ruby/ruby/blob/trunk/parse.y#L10679
 	return ID2SYM(id);
     }
 
-    dup = rb_str_dup(str);
     enc = rb_enc_get(str);
     ascii = rb_usascii_encoding();
     if (enc != ascii) {
 	if (sym_check_asciionly(str)) {
+	    str = rb_str_dup(str);
 	    rb_enc_associate(dup, ascii);
+	    OBJ_FREEZE(str);
 	}
     }
 
     type = rb_str_symname_type(str, TRUE);
-    OBJ_FREEZE(dup);
-    str = rb_fstring(dup);
+    str = rb_fstring(str);
     dsym = rb_newobj_of(rb_cSymbol, T_SYMBOL);
     OBJ_FREEZE(dsym);
     RSYMBOL(dsym)->fstr = str;

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

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