ruby-changes:28638
From: ko1 <ko1@a...>
Date: Mon, 13 May 2013 18:56:41 +0900 (JST)
Subject: [ruby-changes:28638] ko1:r40690 (trunk): * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
ko1 2013-05-13 18:56:22 +0900 (Mon, 13 May 2013) New Revision: 40690 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40690 Log: * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro instead of using RARRAY_PTR(). Modified files: trunk/ChangeLog trunk/array.c trunk/compile.c trunk/complex.c trunk/enum.c trunk/enumerator.c trunk/error.c trunk/eval_error.c trunk/file.c trunk/gc.c trunk/hash.c trunk/insns.def trunk/io.c trunk/iseq.c trunk/load.c trunk/marshal.c trunk/numeric.c trunk/pack.c trunk/parse.y trunk/proc.c trunk/process.c trunk/range.c trunk/rational.c trunk/re.c trunk/ruby.c trunk/string.c trunk/struct.c trunk/thread.c trunk/transcode.c trunk/vm.c trunk/vm_dump.c trunk/vm_eval.c trunk/vm_method.c Index: complex.c =================================================================== --- complex.c (revision 40689) +++ complex.c (revision 40690) @@ -1357,8 +1357,8 @@ nucomp_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/complex.c#L1357 Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled complex must have an array whose length is 2 but %ld", RARRAY_LEN(a)); - rb_ivar_set(self, id_i_real, RARRAY_PTR(a)[0]); - rb_ivar_set(self, id_i_imag, RARRAY_PTR(a)[1]); + rb_ivar_set(self, id_i_real, RARRAY_AREF(a, 0)); + rb_ivar_set(self, id_i_imag, RARRAY_AREF(a, 1)); return self; } Index: array.c =================================================================== --- array.c (revision 40689) +++ array.c (revision 40690) @@ -440,7 +440,7 @@ rb_ary_new3(long n, ...) https://github.com/ruby/ruby/blob/trunk/array.c#L440 va_start(ar, n); for (i=0; i<n; i++) { - RARRAY_PTR(ary)[i] = va_arg(ar, VALUE); + RARRAY_ASET(ary, i, va_arg(ar, VALUE)); } va_end(ar); @@ -742,7 +742,7 @@ rb_ary_store(VALUE ary, long idx, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L742 if (idx >= RARRAY_LEN(ary)) { ARY_SET_LEN(ary, idx + 1); } - RARRAY_PTR(ary)[idx] = val; + RARRAY_ASET(ary, idx, val); } static VALUE @@ -825,7 +825,7 @@ rb_ary_push(VALUE ary, VALUE item) https://github.com/ruby/ruby/blob/trunk/array.c#L825 long idx = RARRAY_LEN(ary); ary_ensure_room_for_push(ary, 1); - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -838,7 +838,7 @@ rb_ary_push_1(VALUE ary, VALUE item) https://github.com/ruby/ruby/blob/trunk/array.c#L838 if (idx >= ARY_CAPA(ary)) { ary_double_capa(ary, idx); } - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -890,7 +890,7 @@ rb_ary_pop(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L890 } n = RARRAY_LEN(ary)-1; ARY_SET_LEN(ary, n); - return RARRAY_PTR(ary)[n]; + return RARRAY_AREF(ary, n); } /* @@ -933,7 +933,7 @@ rb_ary_shift(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L933 rb_ary_modify_check(ary); if (RARRAY_LEN(ary) == 0) return Qnil; - top = RARRAY_PTR(ary)[0]; + top = RARRAY_AREF(ary, 0); if (!ARY_SHARED_P(ary)) { if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) { MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1); @@ -942,11 +942,11 @@ rb_ary_shift(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L942 } assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */ - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); ary_make_shared(ary); } else if (ARY_SHARED_NUM(ARY_SHARED(ary)) == 1) { - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); } ARY_INCREASE_PTR(ary, 1); /* shift ptr */ ARY_INCREASE_LEN(ary, -1); @@ -1095,7 +1095,7 @@ rb_ary_elt(VALUE ary, long offset) https://github.com/ruby/ruby/blob/trunk/array.c#L1095 if (offset < 0 || RARRAY_LEN(ary) <= offset) { return Qnil; } - return RARRAY_PTR(ary)[offset]; + return RARRAY_AREF(ary, offset); } VALUE @@ -1233,7 +1233,7 @@ rb_ary_first(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1233 { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[0]; + return RARRAY_AREF(ary, 0); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST); @@ -1260,7 +1260,7 @@ rb_ary_last(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L1260 { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1]; + return RARRAY_AREF(ary, RARRAY_LEN(ary)-1); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST); @@ -1315,7 +1315,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1315 } return ifnone; } - return RARRAY_PTR(ary)[idx]; + return RARRAY_AREF(ary, idx); } /* @@ -1353,7 +1353,7 @@ rb_ary_index(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1353 if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); for (i=0; i<RARRAY_LEN(ary); i++) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { return LONG2NUM(i); } } @@ -1363,7 +1363,7 @@ rb_ary_index(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1363 if (rb_block_given_p()) rb_warn("given block not used"); for (i=0; i<RARRAY_LEN(ary); i++) { - if (rb_equal(RARRAY_PTR(ary)[i], val)) + if (rb_equal(RARRAY_AREF(ary, i), val)) return LONG2NUM(i); } return Qnil; @@ -1402,7 +1402,7 @@ rb_ary_rindex(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L1402 if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); while (i--) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return LONG2NUM(i); if (i > RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1414,7 +1414,7 @@ rb_ary_rindex(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L1414 if (rb_block_given_p()) rb_warn("given block not used"); while (i--) { - if (rb_equal(RARRAY_PTR(ary)[i], val)) + if (rb_equal(RARRAY_AREF(ary, i), val)) return LONG2NUM(i); if (i > RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1676,7 +1676,7 @@ rb_ary_each(VALUE array) https://github.com/ruby/ruby/blob/trunk/array.c#L1676 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); for (i=0; i<RARRAY_LEN(ary); i++) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } return ary; } @@ -1734,7 +1734,7 @@ rb_ary_reverse_each(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1734 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); len = RARRAY_LEN(ary); while (len--) { - rb_yield(RARRAY_PTR(ary)[len]); + rb_yield(RARRAY_AREF(ary, len)); if (RARRAY_LEN(ary) < len) { len = RARRAY_LEN(ary); } @@ -1819,9 +1819,9 @@ ary_join_0(VALUE ary, VALUE sep, long ma https://github.com/ruby/ruby/blob/trunk/array.c#L1819 long i; VALUE val; - if (max > 0) rb_enc_copy(result, RARRAY_PTR(ary)[0]); + if (max > 0) rb_enc_copy(result, RARRAY_AREF(ary, 0)); for (i=0; i<max; i++) { - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); if (i > 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); rb_str_buf_append(result, val); @@ -1839,7 +1839,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE s https://github.com/ruby/ruby/blob/trunk/array.c#L1839 if (i > 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); if (RB_TYPE_P(val, T_STRING)) { str_join: rb_str_buf_append(result, val); @@ -1900,7 +1900,7 @@ rb_ary_join(VALUE ary, VALUE sep) https://github.com/ruby/ruby/blob/trunk/array.c#L1900 len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1); } for (i=0; i<RARRAY_LEN(ary); i++) { - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); tmp = rb_check_string_type(val); if (NIL_P(tmp) || tmp != val) { @@ -1961,7 +1961,7 @@ inspect_ary(VALUE ary, VALUE dummy, int https://github.com/ruby/ruby/blob/trunk/array.c#L1961 if (recur) return rb_usascii_str_new_cstr("[...]"); str = rb_str_buf_new2("["); for (i=0; i<RARRAY_LEN(ary); i++) { - s = rb_inspect(RARRAY_PTR(ary)[i]); + s = rb_inspect(RARRAY_AREF(ary, i)); if (OBJ_TAINTED(s)) tainted = TRUE; if (OBJ_UNTRUSTED(s)) untrust = TRUE; if (i > 0) rb_str_buf_cat2(str, ", "); @@ -2539,7 +2539,7 @@ rb_ary_collect(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2539 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_push(collect, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); } return collect; } @@ -2572,7 +2572,7 @@ rb_ary_collect_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2572 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_store(ary, i, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_store(ary, i, rb_yield(RARRAY_AREF(ary, i))); } return ary; } @@ -2655,7 +2655,7 @@ rb_ary_select(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2655 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); result = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { rb_ary_push(result, rb_ary_elt(ary, i)); } } @@ -2686,7 +2686,7 @@ rb_ary_select_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2686 RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE v = RARRAY_PTR(ary)[i1]; + VALUE v = RARRAY_AREF(ary, i1); if (!RTEST(rb_yield(v))) continue; if (i1 != i2) { rb_ary_store(ary, i2, v); @@ -2764,7 +2764,7 @@ rb_ary_delete(VALUE ary, VALUE item) https://github.com/ruby/ruby/blob/trunk/array.c#L2764 long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (rb_equal(e, item)) { v = e; @@ -2793,7 +2793,7 @@ rb_ary_delete_same(VALUE ary, VALUE item https://github.com/ruby/ruby/blob/trunk/array.c#L2793 long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (e == item) { continue; @@ -2823,7 +2823,7 @@ rb_ary_delete_at(VALUE ary, long pos) https://github.com/ruby/ruby/blob/trunk/array.c#L2823 } rb_ary_modify(ary); - del = RARRAY_PTR(ary)[pos]; + del = RARRAY_AREF(ary, pos); MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE, RARRAY_LEN(ary)-pos-1); ARY_INCREASE_LEN(ary, -1); @@ -2930,7 +2930,7 @@ ary_reject(VALUE orig, VALUE result) https://github.com/ruby/ruby/blob/trunk/array.c#L2930 long i; for (i = 0; i < RARRAY_LEN(orig); i++) { - VALUE v = RARRAY_PTR(orig)[i]; + VALUE v = RARRAY_AREF(orig, i); if (!RTEST(rb_yield(v))) { rb_ary_push_1(result, v); } @@ -2946,7 +2946,7 @@ ary_reject_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2946 rb_ary_modify_check(ary); for (i = 0; i < RARRAY_LEN(ary); ) { - VALUE v = RARRAY_PTR(ary)[i]; + VALUE v = RARRAY_AREF(ary, i); if (RTEST(rb_yield(v))) { rb_ary_delete_at(ary, i); result = ary; @@ -3323,7 +3323,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L3323 for (i=beg; i<end; i++) { v = rb_yield(LONG2NUM(i)); if (i>=RARRAY_LEN(ary)) break; - RARRAY_PTR(ary)[i] = v; + RARRAY_ASET(ary, i, v); } } else { @@ -3482,9 +3482,9 @@ rb_ary_assoc(VALUE ary, VALUE key) https://github.com/ruby/ruby/blob/trunk/array.c#L3482 VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = rb_check_array_type(RARRAY_PTR(ary)[i]); + v = rb_check_array_type(RARRAY_AREF(ary, i)); if (!NIL_P(v) && RARRAY_LEN(v) > 0 && - rb_equal(RARRAY_PTR(v)[0], key)) + rb_equal(RARRAY_AREF(v, 0), key)) return v; } return Qnil; @@ -3515,10 +3515,10 @@ rb_ary_rassoc(VALUE ary, VALUE value) https://github.com/ruby/ruby/blob/trunk/array.c#L3515 VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = RARRAY_PTR(ary)[i]; + v = RARRAY_AREF(ary, i); if (RB_TYPE_P(v, T_ARRAY) && RARRAY_LEN(v) > 1 && - rb_equal(RARRAY_PTR(v)[1], value)) + rb_equal(RARRAY_AREF(v, 1), value)) return v; } return Qnil; @@ -3628,7 +3628,7 @@ recursive_hash(VALUE ary, VALUE dummy, i https://github.com/ruby/ruby/blob/trunk/array.c#L3628 } else { for (i=0; i<RARRAY_LEN(ary); i++) { - n = rb_hash(RARRAY_PTR(ary)[i]); + n = rb_hash(RARRAY_AREF(ary, i)); h = rb_hash_uint(h, NUM2LONG(n)); } } @@ -3670,7 +3670,7 @@ rb_ary_includes(VALUE ary, VALUE item) https://github.com/ruby/ruby/blob/trunk/array.c#L3670 long i; for (i=0; i<RARRAY_LEN(ary); i++) { - if (rb_equal(RARRAY_PTR(ary)[i], item)) { + if (rb_equal(RARRAY_AREF(ary, i), item)) { return Qtrue; } } @@ -3745,7 +3745,7 @@ ary_add_hash(VALUE hash, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L3745 long i; for (i=0; i<RARRAY_LEN(ary); i++) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], Qtrue); + rb_hash_aset(hash, RARRAY_AREF(ary, i), Qtrue); } return hash; } @@ -3825,7 +3825,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) https://github.com/ruby/ruby/blob/trunk/array.c#L3825 ary3 = rb_ary_new(); for (i=0; i<RARRAY_LEN(ary1); i++) { - if (st_lookup(RHASH_TBL(hash), RARRAY_PTR(ary1)[i], 0)) continue; + if (st_lookup(RHASH_TBL(hash), RARRAY_AREF(ary1, i), 0)) continue; rb_ary_push(ary3, rb_ary_elt(ary1, i)); } ary_recycle_hash(hash); @@ -4158,7 +4158,7 @@ flatten(VALUE ary, int level, int *modif https://github.com/ruby/ruby/blob/trunk/array.c#L4158 while (1) { while (i < RARRAY_LEN(ary)) { - elt = RARRAY_PTR(ary)[i++]; + elt = RARRAY_AREF(ary, i++); tmp = rb_check_array_type(elt); if (RBASIC(result)->klass) { rb_raise(rb_eRuntimeError, "flatten reentered"); @@ -4483,7 +4483,7 @@ rb_ary_cycle_size(VALUE self, VALUE args https://github.com/ruby/ruby/blob/trunk/array.c#L4483 long mul; VALUE n = Qnil; if (args && (RARRAY_LEN(args) > 0)) { - n = RARRAY_PTR(args)[0]; + n = RARRAY_AREF(args, 0); } if (RARRAY_LEN(self) == 0) return INT2FIX(0); if (n == Qnil) return DBL2NUM(INFINITY); @@ -4531,7 +4531,7 @@ rb_ary_cycle(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L4531 while (RARRAY_LEN(ary) > 0 && (n < 0 || 0 < n--)) { for (i=0; i<RARRAY_LEN(ary); i++) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } } return Qnil; @@ -4618,7 +4618,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L4618 rb_ary_permutation_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = (args && (RARRAY_LEN(args) > 0)) ? NUM2LONG(RARRAY_PTR(args)[0]) : n; + long k = (args && (RARRAY_LEN(args) > 0)) ? NUM2LONG(RARRAY_AREF(args, 0)) : n; return descending_factorial(n, k); } @@ -4670,7 +4670,7 @@ rb_ary_permutation(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/array.c#L4670 } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4695,7 +4695,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L4695 rb_ary_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); return binomial_coefficient(k, n); } @@ -4741,7 +4741,7 @@ rb_ary_combination(VALUE ary, VALUE num) https://github.com/ruby/ruby/blob/trunk/array.c#L4741 } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { @@ -4754,9 +4754,9 @@ rb_ary_combination(VALUE ary, VALUE num) https://github.com/ruby/ruby/blob/trunk/array.c#L4754 MEMZERO(stack, long, n); stack[0] = -1; for (;;) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1]]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1]); for (lev++; lev < n; lev++) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1] = stack[lev]+1]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1] = stack[lev]+1); } rb_yield(rb_ary_new4(n, chosen)); if (RBASIC(t0)->klass) { @@ -4818,7 +4818,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L4818 rb_ary_repeated_permutation_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k < 0) { return LONG2FIX(0); @@ -4867,7 +4867,7 @@ rb_ary_repeated_permutation(VALUE ary, V https://github.com/ruby/ruby/blob/trunk/array.c#L4867 } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4911,7 +4911,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L4911 rb_ary_repeated_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k == 0) { return LONG2FIX(1); } @@ -4961,7 +4961,7 @@ rb_ary_repeated_combination(VALUE ary, V https://github.com/ruby/ruby/blob/trunk/array.c#L4961 } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else if (len == 0) { @@ -5139,7 +5139,7 @@ rb_ary_take_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5139 RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_take(ary, LONG2FIX(i)); } @@ -5199,7 +5199,7 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5199 RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_drop(ary, LONG2FIX(i)); } Index: ChangeLog =================================================================== --- ChangeLog (revision 40689) +++ ChangeLog (revision 40690) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon May 13 18:44:14 2013 Koichi Sasada <ko1@a...> + + * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro + instead of using RARRAY_PTR(). + Mon May 13 16:53:53 2013 Koichi Sasada <ko1@a...> * include/ruby/ruby.h: add new utility macros to access Index: insns.def =================================================================== --- insns.def (revision 40689) +++ insns.def (revision 40690) @@ -818,7 +818,7 @@ checkmatch https://github.com/ruby/ruby/blob/trunk/insns.def#L818 if (flag & VM_CHECKMATCH_ARRAY) { int i; for (i = 0; i < RARRAY_LEN(pattern); i++) { - if (RTEST(check_match(RARRAY_PTR(pattern)[i], target, checkmatch_type))) { + if (RTEST(check_match(RARRAY_AREF(pattern, i), target, checkmatch_type))) { result = Qtrue; break; } Index: re.c =================================================================== --- re.c (revision 40689) +++ re.c (revision 40690) @@ -2342,7 +2342,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int https://github.com/ruby/ruby/blob/trunk/re.c#L2342 } for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE str = RARRAY_PTR(ary)[i]; + VALUE str = RARRAY_AREF(ary, i); VALUE buf; char *p, *end; rb_encoding *src_enc; Index: enumerator.c =================================================================== --- enumerator.c (revision 40689) +++ enumerator.c (revision 40690) @@ (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/