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

ruby-changes:39993

From: nobu <ko1@a...>
Date: Wed, 7 Oct 2015 21:33:04 +0900 (JST)
Subject: [ruby-changes:39993] nobu:r52074 (trunk): string.c: str_duplicate

nobu	2015-10-07 21:32:54 +0900 (Wed, 07 Oct 2015)

  New Revision: 52074

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

  Log:
    string.c: str_duplicate
    
    * string.c (str_duplicate): move from rb_str_resurrect to short
      circuit initialization.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52073)
+++ ChangeLog	(revision 52074)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Oct  7 21:32:51 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (str_duplicate): move from rb_str_resurrect to short
+	  circuit initialization.
+
 Wed Oct  7 20:43:14 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (rb_str_resurrect): fix resurrection of short enough to
Index: string.c
===================================================================
--- string.c	(revision 52073)
+++ string.c	(revision 52074)
@@ -1236,20 +1236,6 @@ str_replace(VALUE str, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L1236
 static VALUE
 str_duplicate(VALUE klass, VALUE str)
 {
-    VALUE dup = str_alloc(klass);
-    str_replace(dup, str);
-    return dup;
-}
-
-VALUE
-rb_str_dup(VALUE str)
-{
-    return str_duplicate(rb_obj_class(str), str);
-}
-
-VALUE
-rb_str_resurrect(VALUE str)
-{
     enum {embed_size = RSTRING_EMBED_LEN_MAX + 1};
     const VALUE flag_mask =
 	RSTRING_NOEMBED | RSTRING_EMBED_LEN_MASK |
@@ -1257,18 +1243,12 @@ rb_str_resurrect(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L1243
 	FL_TAINT | FL_FREEZE
 	;
     VALUE flags = FL_TEST_RAW(str, flag_mask);
-    VALUE dup;
-
-    if (RUBY_DTRACE_STRING_CREATE_ENABLED()) {
-	RUBY_DTRACE_STRING_CREATE(RSTRING_LEN(str),
-				  rb_sourcefile(), rb_sourceline());
-    }
-    dup = str_alloc(rb_cString);
+    VALUE dup = str_alloc(klass);
     MEMCPY(RSTRING(dup)->as.ary, RSTRING(str)->as.ary,
 	   char, embed_size);
     if (flags & STR_NOEMBED) {
 	if (UNLIKELY(!(flags & FL_FREEZE))) {
-	    str = str_new_frozen(rb_cString, str);
+	    str = str_new_frozen(klass, str);
 	    FL_SET_RAW(str, flags & FL_TAINT);
 	    flags = FL_TEST_RAW(str, flag_mask);
 	}
@@ -1285,6 +1265,22 @@ rb_str_resurrect(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L1265
     return dup;
 }
 
+VALUE
+rb_str_dup(VALUE str)
+{
+    return str_duplicate(rb_obj_class(str), str);
+}
+
+VALUE
+rb_str_resurrect(VALUE str)
+{
+    if (RUBY_DTRACE_STRING_CREATE_ENABLED()) {
+	RUBY_DTRACE_STRING_CREATE(RSTRING_LEN(str),
+				  rb_sourcefile(), rb_sourceline());
+    }
+    return str_duplicate(rb_cString, str);
+}
+
 /*
  *  call-seq:
  *     String.new(str="")   -> new_str

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

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