diff --git a/ChangeLog b/ChangeLog index 2d85de32e1..ab223a1501 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 13 11:35:55 2009 NARUSE, Yui + + * sprintf.c (rb_str_format): optimize previous commit. + [ruby-list:45954] + Mon Apr 13 10:58:54 2009 NARUSE, Yui * sprintf.c (rb_str_format): check encoding compatibility only on diff --git a/sprintf.c b/sprintf.c index 2bcf138c27..c276761bf2 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) {