mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (ARY_SET): added.
ARY_SET() is same functionality of RARRAY_ASET(), but it has an assertion (`ary' doesn't have shared array). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6bc463204a
commit
f2606d6250
2 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
Fri Apr 11 18:52:38 2014 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* array.c (ARY_SET): added.
|
||||
|
||||
ARY_SET() is same functionality of RARRAY_ASET(), but
|
||||
it has an assertion (`ary' doesn't have shared array).
|
||||
|
||||
Fri Apr 11 16:54:26 2014 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* array.c: make shared arrays WB-protected objects.
|
||||
|
|
12
array.c
12
array.c
|
@ -131,6 +131,8 @@ static ID id_cmp, id_div, id_power;
|
|||
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
|
||||
} while (0)
|
||||
|
||||
#define ARY_SET(a, i, v) RARRAY_ASET((assert(!ARY_SHARED_P(a)), (a)), (i), (v))
|
||||
|
||||
void
|
||||
rb_mem_clear(register VALUE *mem, register long size)
|
||||
{
|
||||
|
@ -520,7 +522,7 @@ rb_ary_new_from_args(long n, ...)
|
|||
|
||||
va_start(ar, n);
|
||||
for (i=0; i<n; i++) {
|
||||
RARRAY_ASET(ary, i, va_arg(ar, VALUE));
|
||||
ARY_SET(ary, i, va_arg(ar, VALUE));
|
||||
}
|
||||
va_end(ar);
|
||||
|
||||
|
@ -827,7 +829,7 @@ rb_ary_store(VALUE ary, long idx, VALUE val)
|
|||
if (idx >= len) {
|
||||
ARY_SET_LEN(ary, idx + 1);
|
||||
}
|
||||
RARRAY_ASET(ary, idx, val);
|
||||
ARY_SET(ary, idx, val);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1020,11 +1022,11 @@ rb_ary_shift(VALUE ary)
|
|||
}
|
||||
assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */
|
||||
|
||||
RARRAY_ASET(ary, 0, Qnil);
|
||||
ARY_SET(ary, 0, Qnil);
|
||||
ary_make_shared(ary);
|
||||
}
|
||||
else if (ARY_SHARED_OCCUPIED(ARY_SHARED(ary))) {
|
||||
RARRAY_ASET(ary, 0, Qnil);
|
||||
RARRAY_PTR_USE(ary, ptr, ptr[0] = Qnil);
|
||||
}
|
||||
ARY_INCREASE_PTR(ary, 1); /* shift ptr */
|
||||
ARY_INCREASE_LEN(ary, -1);
|
||||
|
@ -3504,7 +3506,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
|
|||
for (i=beg; i<end; i++) {
|
||||
v = rb_yield(LONG2NUM(i));
|
||||
if (i>=RARRAY_LEN(ary)) break;
|
||||
RARRAY_ASET(ary, i, v);
|
||||
ARY_SET(ary, i, v);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue