summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-13 02:40:20 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-13 02:40:20 +0000
commitb2ac99dfa3328ff37bad39bf069a5f9e6f1621c8 (patch)
tree19e92dab0b08c62af5a4c73fbdc86c9bc22ab034 /sprintf.c
parent87335c3e2f04f946b768a46e677f576863665cbb (diff)
* sprintf.c (rb_str_format): optimize previous commit.
[ruby-list:45954] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index 2bcf138..c276761 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -660,7 +660,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
str = rb_obj_as_string(arg);
if (OBJ_TAINTED(str)) tainted = 1;
len = RSTRING_LEN(str);
- enc = rb_enc_check(rb_str_substr(result, 0, blen), str);
+ rb_str_set_len(result, blen);
+ enc = rb_enc_check(result, str);
if (flags&(FPREC|FWIDTH)) {
slen = rb_enc_strlen(RSTRING_PTR(str),RSTRING_END(str),enc);
if (slen < 0) {