ruby-changes:5011
From: ko1@a...
Date: Wed, 21 May 2008 16:50:47 +0900 (JST)
Subject: [ruby-changes:5011] matz - Ruby:r16504 (trunk): * array.c (rb_ary_compact_bang): avoid forceful realloc.
matz 2008-05-21 16:50:27 +0900 (Wed, 21 May 2008) New Revision: 16504 Modified files: trunk/ChangeLog trunk/array.c Log: * array.c (rb_ary_compact_bang): avoid forceful realloc. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/array.c?r1=16504&r2=16503&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16504&r2=16503&diff_format=u Index: array.c =================================================================== --- array.c (revision 16503) +++ array.c (revision 16504) @@ -2710,11 +2710,13 @@ if (NIL_P(*t)) t++; else *p++ = *t++; } - if (RARRAY_LEN(ary) == (p - RARRAY_PTR(ary))) { + n = p - RARRAY_PTR(ary); + if (RARRAY_LEN(ary) == n) { return Qnil; } - n = p - RARRAY_PTR(ary); - RESIZE_CAPA(ary, n); + if (n * 2 < ARY_CAPA(ary) && ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) { + RESIZE_CAPA(ary, ARY_DEFAULT_SIZE * 2); + } RARRAY(ary)->len = n; return ary; Index: ChangeLog =================================================================== --- ChangeLog (revision 16503) +++ ChangeLog (revision 16504) @@ -1,3 +1,7 @@ +Wed May 21 16:48:22 2008 Yukihiro Matsumoto <matz@r...> + + * array.c (rb_ary_compact_bang): avoid forceful realloc. + Wed May 21 07:42:28 2008 NARUSE, Yui <naruse@r...> * string.c (rb_usascii_str_new): use rb_str_new. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/