1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_clear): should not unshare embedded array, and

should make unshared array embedded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-07-19 03:33:33 +00:00
parent 4d5eee3602
commit 87d8a3b9ce
2 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Jul 19 12:33:29 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_clear): should not unshare embedded array, and
should make unshared array embedded.
Mon Jul 19 09:00:58 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* NEWS (Kernel#instance_eval): add an incompatible change since

View file

@ -2775,7 +2775,10 @@ rb_ary_clear(VALUE ary)
rb_ary_modify_check(ary);
ARY_SET_LEN(ary, 0);
if (ARY_SHARED_P(ary)) {
rb_ary_unshare(ary);
if (!ARY_EMBED_P(ary)) {
rb_ary_unshare(ary);
FL_SET_EMBED(ary);
}
}
else if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
ary_resize_capa(ary, ARY_DEFAULT_SIZE * 2);