зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_sort_bang): replacing array during sort broke
invariant of array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2a3d7b5992
Коммит
0d83c7b6c2
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Oct 29 23:57:29 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* array.c (rb_ary_sort_bang): replacing array during sort broke
|
||||||
|
invariant of array.
|
||||||
|
|
||||||
Wed Oct 29 20:45:08 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
Wed Oct 29 20:45:08 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* test/webrick/utils.rb (start_server): provide a reference to log of
|
* test/webrick/utils.rb (start_server): provide a reference to log of
|
||||||
|
|
8
array.c
8
array.c
|
@ -1751,14 +1751,18 @@ rb_ary_sort_bang(VALUE ary)
|
||||||
ruby_qsort(RARRAY_PTR(tmp), RARRAY_LEN(tmp), sizeof(VALUE),
|
ruby_qsort(RARRAY_PTR(tmp), RARRAY_LEN(tmp), sizeof(VALUE),
|
||||||
rb_block_given_p()?sort_1:sort_2, &data);
|
rb_block_given_p()?sort_1:sort_2, &data);
|
||||||
|
|
||||||
if (ARY_EMBED_P(ary) || ARY_EMBED_P(tmp)) {
|
if (ARY_EMBED_P(tmp)) {
|
||||||
assert(ARY_EMBED_P(tmp));
|
assert(ARY_EMBED_P(tmp));
|
||||||
|
if (ARY_SHARED_P(ary)) { /* ary might be destructively operated in the given block */
|
||||||
|
rb_ary_unshare(ary);
|
||||||
|
FL_SET_EMBED(ary);
|
||||||
|
}
|
||||||
MEMCPY(RARRAY_PTR(ary), ARY_EMBED_PTR(tmp), VALUE, ARY_EMBED_LEN(tmp));
|
MEMCPY(RARRAY_PTR(ary), ARY_EMBED_PTR(tmp), VALUE, ARY_EMBED_LEN(tmp));
|
||||||
ARY_SET_LEN(ary, ARY_EMBED_LEN(tmp));
|
ARY_SET_LEN(ary, ARY_EMBED_LEN(tmp));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(!ARY_EMBED_P(ary));
|
|
||||||
assert(!ARY_EMBED_P(tmp));
|
assert(!ARY_EMBED_P(tmp));
|
||||||
|
if (ARY_EMBED_P(ary)) FL_UNSET_EMBED(ary);
|
||||||
if (RARRAY_PTR(ary) != RARRAY_PTR(tmp)) {
|
if (RARRAY_PTR(ary) != RARRAY_PTR(tmp)) {
|
||||||
assert(!ARY_SHARED_P(tmp));
|
assert(!ARY_SHARED_P(tmp));
|
||||||
if (ARY_SHARED_P(ary)) {
|
if (ARY_SHARED_P(ary)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче