ruby-changes:30060
From: glass <ko1@a...>
Date: Mon, 22 Jul 2013 18:04:01 +0900 (JST)
Subject: [ruby-changes:30060] glass:r42112 (trunk): * string.c (rb_str_enumerate_chars): specify array capa.
glass 2013-07-22 18:03:44 +0900 (Mon, 22 Jul 2013) New Revision: 42112 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42112 Log: * string.c (rb_str_enumerate_chars): specify array capa. Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42111) +++ ChangeLog (revision 42112) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 22 18:01:33 2013 Masaki Matsushita <glass.saga@g...> + + * string.c (rb_str_enumerate_chars): specify array capa. + Mon Jul 22 17:24:14 2013 Masaki Matsushita <glass.saga@g...> * string.c (rb_str_each_char_size): performance improvement by Index: string.c =================================================================== --- string.c (revision 42111) +++ string.c (revision 42112) @@ -6518,7 +6518,7 @@ rb_str_enumerate_chars(VALUE str, int wa https://github.com/ruby/ruby/blob/trunk/string.c#L6518 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 wa https://github.com/ruby/ruby/blob/trunk/string.c#L6527 } 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/