mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_shift, rb_ary_shift_m): clears unused elements.
[ruby-dev:38448] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f4a0a73175
commit
62e5fa1737
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri May 15 17:35:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_shift, rb_ary_shift_m): clears unused elements.
|
||||
[ruby-dev:38448]
|
||||
|
||||
Fri May 15 15:15:12 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* variable.c (rb_autoload_load): checks if iv_tbl is valid.
|
||||
|
|
6
array.c
6
array.c
|
@ -807,6 +807,9 @@ rb_ary_shift(VALUE ary)
|
|||
RARRAY_PTR(ary)[0] = Qnil;
|
||||
ary_make_shared(ary);
|
||||
}
|
||||
else if (ARY_SHARED_NUM(ARY_SHARED(ary)) == 1) {
|
||||
RARRAY_PTR(ary)[0] = Qnil;
|
||||
}
|
||||
ARY_INCREASE_PTR(ary, 1); /* shift ptr */
|
||||
ARY_INCREASE_LEN(ary, -1);
|
||||
|
||||
|
@ -848,6 +851,9 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
|
|||
result = ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST);
|
||||
n = RARRAY_LEN(result);
|
||||
if (ARY_SHARED_P(ary)) {
|
||||
if (ARY_SHARED_NUM(ARY_SHARED(ary)) == 1) {
|
||||
rb_mem_clear(RARRAY_PTR(ary), n);
|
||||
}
|
||||
ARY_INCREASE_PTR(ary, n);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue