diff --git a/ChangeLog b/ChangeLog index 7c0f6b8a05..baa929f68a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jul 22 18:01:33 2013 Masaki Matsushita + + * string.c (rb_str_enumerate_chars): specify array capa. + Mon Jul 22 17:24:14 2013 Masaki Matsushita * string.c (rb_str_each_char_size): performance improvement by diff --git a/string.c b/string.c index e5d04cddc6..a4c76d4f7b 100644 --- a/string.c +++ b/string.c @@ -6518,7 +6518,7 @@ rb_str_enumerate_chars(VALUE str, int wantarray) if (wantarray) { #if STRING_ENUMERATORS_WANTARRAY rb_warn("given block not used"); - ary = rb_ary_new(); + ary = rb_ary_new_capa(rb_str_strlen(str)); #else rb_warning("passing a block to String#chars is deprecated"); wantarray = 0; @@ -6527,7 +6527,7 @@ rb_str_enumerate_chars(VALUE str, int wantarray) } else { if (wantarray) - ary = rb_ary_new(); + ary = rb_ary_new_capa(rb_str_strlen(str)); else RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); }