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

ruby-changes:39271

From: nobu <ko1@a...>
Date: Thu, 23 Jul 2015 10:16:58 +0900 (JST)
Subject: [ruby-changes:39271] nobu:r51352 (trunk): string.c: str_shared_replace

nobu	2015-07-23 10:16:46 +0900 (Thu, 23 Jul 2015)

  New Revision: 51352

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

  Log:
    string.c: str_shared_replace
    
    * string.c (str_shared_replace): split from rb_str_shared_replace
      without argument check.

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 51351)
+++ string.c	(revision 51352)
@@ -1105,13 +1105,21 @@ rb_str_to_str(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L1105
 }
 
 static inline void str_discard(VALUE str);
+static void str_shared_replace(VALUE str, VALUE str2);
 
 void
 rb_str_shared_replace(VALUE str, VALUE str2)
 {
+    if (str != str2) str_shared_replace(str, str2);
+}
+
+static void
+str_shared_replace(VALUE str, VALUE str2)
+{
     rb_encoding *enc;
     int cr;
-    if (str == str2) return;
+
+    ASSUME(str2 != str);
     enc = STR_ENC_GET(str2);
     cr = ENC_CODERANGE(str2);
     str_discard(str);
@@ -4477,7 +4485,7 @@ str_gsub(int argc, VALUE *argv, VALUE st https://github.com/ruby/ruby/blob/trunk/string.c#L4485
     }
     rb_pat_search(pat, str, last, 1);
     if (bang) {
-        rb_str_shared_replace(str, dest);
+        str_shared_replace(str, dest);
     }
     else {
 	RBASIC_SET_CLASS(dest, rb_obj_class(str));
@@ -4872,7 +4880,7 @@ rb_str_reverse_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L4880
 	    }
 	}
 	else {
-	    rb_str_shared_replace(str, rb_str_reverse(str));
+	    str_shared_replace(str, rb_str_reverse(str));
 	}
     }
     else {

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

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