зеркало из https://github.com/github/ruby.git
array.c add back shared array optimization to ary_ensure_room_for_unshift
Bug fix in commit ec8e5f5aa6
[Bug #15952] disabled an
optimization in this function.
Closes: https://github.com/ruby/ruby/pull/2252
This commit is contained in:
Родитель
ec8e5f5aa6
Коммит
5a187e26ad
4
array.c
4
array.c
|
@ -1373,18 +1373,18 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
|
|||
rb_raise(rb_eIndexError, "index %ld too big", new_len);
|
||||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
|
||||
if (ARY_SHARED_P(ary)) {
|
||||
VALUE shared = ARY_SHARED(ary);
|
||||
capa = RARRAY_LEN(shared);
|
||||
if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
|
||||
rb_ary_modify_check(ary);
|
||||
head = RARRAY_CONST_PTR_TRANSIENT(ary);
|
||||
sharedp = RARRAY_CONST_PTR_TRANSIENT(shared);
|
||||
goto makeroom_if_need;
|
||||
}
|
||||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
capa = ARY_CAPA(ary);
|
||||
if (capa - (capa >> 6) <= new_len) {
|
||||
ary_double_capa(ary, new_len);
|
||||
|
|
Загрузка…
Ссылка в новой задаче