зеркало из https://github.com/github/ruby.git
* 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:
Родитель
6bc463204a
Коммит
f2606d6250
|
@ -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>
|
Fri Apr 11 16:54:26 2014 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* array.c: make shared arrays WB-protected objects.
|
* 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); \
|
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define ARY_SET(a, i, v) RARRAY_ASET((assert(!ARY_SHARED_P(a)), (a)), (i), (v))
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mem_clear(register VALUE *mem, register long size)
|
rb_mem_clear(register VALUE *mem, register long size)
|
||||||
{
|
{
|
||||||
|
@ -520,7 +522,7 @@ rb_ary_new_from_args(long n, ...)
|
||||||
|
|
||||||
va_start(ar, n);
|
va_start(ar, n);
|
||||||
for (i=0; i<n; i++) {
|
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);
|
va_end(ar);
|
||||||
|
|
||||||
|
@ -827,7 +829,7 @@ rb_ary_store(VALUE ary, long idx, VALUE val)
|
||||||
if (idx >= len) {
|
if (idx >= len) {
|
||||||
ARY_SET_LEN(ary, idx + 1);
|
ARY_SET_LEN(ary, idx + 1);
|
||||||
}
|
}
|
||||||
RARRAY_ASET(ary, idx, val);
|
ARY_SET(ary, idx, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1020,11 +1022,11 @@ rb_ary_shift(VALUE ary)
|
||||||
}
|
}
|
||||||
assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */
|
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);
|
ary_make_shared(ary);
|
||||||
}
|
}
|
||||||
else if (ARY_SHARED_OCCUPIED(ARY_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_PTR(ary, 1); /* shift ptr */
|
||||||
ARY_INCREASE_LEN(ary, -1);
|
ARY_INCREASE_LEN(ary, -1);
|
||||||
|
@ -3504,7 +3506,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
|
||||||
for (i=beg; i<end; i++) {
|
for (i=beg; i<end; i++) {
|
||||||
v = rb_yield(LONG2NUM(i));
|
v = rb_yield(LONG2NUM(i));
|
||||||
if (i>=RARRAY_LEN(ary)) break;
|
if (i>=RARRAY_LEN(ary)) break;
|
||||||
RARRAY_ASET(ary, i, v);
|
ARY_SET(ary, i, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче