mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
* array.c (rb_ary_clear): no need to duplicate buffer just before
clearing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
25b9eb5e57
commit
10a90fbce8
2 changed files with 10 additions and 2 deletions
7
array.c
7
array.c
|
@ -2772,9 +2772,12 @@ rb_ary_replace(VALUE copy, VALUE orig)
|
|||
VALUE
|
||||
rb_ary_clear(VALUE ary)
|
||||
{
|
||||
rb_ary_modify(ary);
|
||||
rb_ary_modify_check(ary);
|
||||
ARY_SET_LEN(ary, 0);
|
||||
if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
|
||||
if (ARY_SHARED_P(ary)) {
|
||||
rb_ary_unshare(ary);
|
||||
}
|
||||
else if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
|
||||
ary_resize_capa(ary, ARY_DEFAULT_SIZE * 2);
|
||||
}
|
||||
return ary;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue