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

ruby-changes:18969

From: naruse <ko1@a...>
Date: Wed, 2 Mar 2011 14:09:43 +0900 (JST)
Subject: [ruby-changes:18969] Ruby:r31004 (trunk): * string.c (rb_str_slice_bang): move treatments which is only needed

naruse	2011-03-02 14:09:37 +0900 (Wed, 02 Mar 2011)

  New Revision: 31004

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

  Log:
    * string.c (rb_str_slice_bang): move treatments which is only needed
      when the result is not nil.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31003)
+++ ChangeLog	(revision 31004)
@@ -1,3 +1,8 @@
+Wed Mar  2 14:06:01 2011  NARUSE, Yui  <naruse@r...>
+
+	* string.c (rb_str_slice_bang): move treatments which is only needed
+	  when the result is not nil.
+
 Wed Mar  2 14:02:29 2011  Shota Fukumori  <sorah@t...>
 
 	* test/testunit/test_parallel.rb(TestParallel#spawn_runner):
Index: string.c
===================================================================
--- string.c	(revision 31003)
+++ string.c	(revision 31004)
@@ -3503,10 +3503,10 @@
     for (i=0; i<argc; i++) {
 	buf[i] = argv[i];
     }
-    str_modify_keep_cr(str);
-    buf[i] = rb_str_new(0,0);
     result = rb_str_aref_m(argc, buf, str);
     if (!NIL_P(result)) {
+	str_modify_keep_cr(str);
+	buf[i] = rb_str_new(0,0);
 	rb_str_aset_m(argc+1, buf, str);
     }
     return result;
@@ -4073,8 +4073,8 @@
  *     "hello".byteslice(1)     #=> "e"
  *     "hello".byteslice(-1)    #=> "o"
  *     "hello".byteslice(1, 2)  #=> "el"
- *     "\u3042".byteslice(1, 2) #=> "\x81\x82"
- *     "\u3042".byteslice(1..3) #=> "\x81\x82"
+ *     "\x80\u3042".byteslice(1, 3) #=> "\u3042"
+ *     "\x03\u3042\xff".byteslice(1..3) #=> "\u3942"
  */
 
 static VALUE

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

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