From eace50a9d79e1f3ec58011b8238d0b79e9a716b6 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 29 Sep 2008 14:39:20 +0000 Subject: [PATCH] * string.c (rb_str_subseq): don't use rb_str_drop_bytes for short string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d129338a47..8f778f1982 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 29 23:32:25 2008 Tanaka Akira + + * string.c (rb_str_subseq): don't use rb_str_drop_bytes for short + string. + Mon Sep 29 22:54:29 2008 Tadayoshi Funaba * lib/mathn.rb: added String#to_[rc]. moved def_canon. diff --git a/string.c b/string.c index cf7f484c7d..6a6859b1f2 100644 --- a/string.c +++ b/string.c @@ -1285,8 +1285,9 @@ rb_str_subseq(VALUE str, long beg, long len) { VALUE str2; - if (RSTRING_LEN(str) == beg + len) { - str2 = rb_str_new_shared(str); + if (RSTRING_LEN(str) == beg + len && + RSTRING_EMBED_LEN_MAX < len) { + str2 = rb_str_new_shared(rb_str_new_frozen(str)); rb_str_drop_bytes(str2, beg); } else {