ruby-changes:33490
From: ko1 <ko1@a...>
Date: Fri, 11 Apr 2014 18:55:19 +0900 (JST)
Subject: [ruby-changes:33490] ko1:r45569 (trunk): * array.c (ARY_SET): added.
ko1 2014-04-11 18:55:10 +0900 (Fri, 11 Apr 2014) New Revision: 45569 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45569 Log: * array.c (ARY_SET): added. ARY_SET() is same functionality of RARRAY_ASET(), but it has an assertion (`ary' doesn't have shared array). Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 45568) +++ array.c (revision 45569) @@ -131,6 +131,8 @@ static ID id_cmp, id_div, id_power; https://github.com/ruby/ruby/blob/trunk/array.c#L131 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, ...) https://github.com/ruby/ruby/blob/trunk/array.c#L522 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 https://github.com/ruby/ruby/blob/trunk/array.c#L829 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) https://github.com/ruby/ruby/blob/trunk/array.c#L1022 } 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 https://github.com/ruby/ruby/blob/trunk/array.c#L3506 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 { Index: ChangeLog =================================================================== --- ChangeLog (revision 45568) +++ ChangeLog (revision 45569) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Apr 11 18:52:38 2014 Koichi Sasada <ko1@a...> + + * 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@a...> * array.c: make shared arrays WB-protected objects. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/