summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-02 05:09:37 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-02 05:09:37 +0000
commita991a12cbc63c803811673fa3b77c035fdf78558 (patch)
treecd213dcff975fb4ad12aeee7938a34895c3a04b2
parent7fd10596b949be1d8c7615add9ba2de7b28642dc (diff)
* string.c (rb_str_slice_bang): move treatments which is only needed
when the result is not nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f7b221128..b4992cd534 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 2 14:06:01 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@tubusu.net>
* test/testunit/test_parallel.rb(TestParallel#spawn_runner):
diff --git a/string.c b/string.c
index 87273de5f1..bb13bd1d8d 100644
--- a/string.c
+++ b/string.c
@@ -3503,10 +3503,10 @@ rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
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 @@ str_byte_aref(VALUE str, VALUE indx)
* "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