зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_compact_bang): avoid forceful realloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a5bbd5b8a5
Коммит
f827d95685
|
@ -1,3 +1,7 @@
|
|||
Wed May 21 16:48:22 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_compact_bang): avoid forceful realloc.
|
||||
|
||||
Wed May 21 07:42:28 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* string.c (rb_usascii_str_new): use rb_str_new.
|
||||
|
|
8
array.c
8
array.c
|
@ -2710,11 +2710,13 @@ rb_ary_compact_bang(VALUE ary)
|
|||
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче