use RARRAY_AREF() instead of RARRAY_CONST_PTR().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2018-10-30 03:21:56 +00:00
parent f7c0cc3692
commit 54726befc3
6 changed files with 21 additions and 27 deletions

View File

@ -5925,7 +5925,6 @@ static VALUE
rb_ary_any_p(int argc, VALUE *argv, VALUE ary) rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
{ {
long i, len = RARRAY_LEN(ary); long i, len = RARRAY_LEN(ary);
const VALUE *ptr = RARRAY_CONST_PTR(ary);
rb_check_arity(argc, 0, 1); rb_check_arity(argc, 0, 1);
if (!len) return Qfalse; if (!len) return Qfalse;
@ -5938,7 +5937,9 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
} }
} }
else if (!rb_block_given_p()) { else if (!rb_block_given_p()) {
for (i = 0; i < len; ++i) if (RTEST(ptr[i])) return Qtrue; for (i = 0; i < len; ++i) {
if (RTEST(RARRAY_AREF(ary, i))) return Qtrue;
}
} }
else { else {
for (i = 0; i < RARRAY_LEN(ary); ++i) { for (i = 0; i < RARRAY_LEN(ary); ++i) {

View File

@ -7754,7 +7754,6 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table,
for (i=0; i<RARRAY_LEN(exception); i++) { for (i=0; i<RARRAY_LEN(exception); i++) {
const rb_iseq_t *eiseq; const rb_iseq_t *eiseq;
VALUE v, type; VALUE v, type;
const VALUE *ptr;
LABEL *lstart, *lend, *lcont; LABEL *lstart, *lend, *lcont;
unsigned int sp; unsigned int sp;
@ -7762,19 +7761,18 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table,
if (RARRAY_LEN(v) != 6) { if (RARRAY_LEN(v) != 6) {
rb_raise(rb_eSyntaxError, "wrong exception entry"); rb_raise(rb_eSyntaxError, "wrong exception entry");
} }
ptr = RARRAY_CONST_PTR(v); type = get_exception_sym2type(RARRAY_AREF(v, 0));
type = get_exception_sym2type(ptr[0]); if (RARRAY_AREF(v, 1) == Qnil) {
if (ptr[1] == Qnil) {
eiseq = NULL; eiseq = NULL;
} }
else { else {
eiseq = rb_iseqw_to_iseq(rb_iseq_load(ptr[1], (VALUE)iseq, Qnil)); eiseq = rb_iseqw_to_iseq(rb_iseq_load(RARRAY_AREF(v, 1), (VALUE)iseq, Qnil));
} }
lstart = register_label(iseq, labels_table, ptr[2]); lstart = register_label(iseq, labels_table, RARRAY_AREF(v, 2));
lend = register_label(iseq, labels_table, ptr[3]); lend = register_label(iseq, labels_table, RARRAY_AREF(v, 3));
lcont = register_label(iseq, labels_table, ptr[4]); lcont = register_label(iseq, labels_table, RARRAY_AREF(v, 4));
sp = NUM2UINT(ptr[5]); sp = NUM2UINT(RARRAY_AREF(v, 5));
/* TODO: Dirty Hack! Fix me */ /* TODO: Dirty Hack! Fix me */
if (type == CATCH_TYPE_RESCUE || if (type == CATCH_TYPE_RESCUE ||
@ -7882,7 +7880,6 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
VALUE body, VALUE labels_wrapper) VALUE body, VALUE labels_wrapper)
{ {
/* TODO: body should be frozen */ /* TODO: body should be frozen */
const VALUE *ptr = RARRAY_CONST_PTR(body);
long i, len = RARRAY_LEN(body); long i, len = RARRAY_LEN(body);
struct st_table *labels_table = DATA_PTR(labels_wrapper); struct st_table *labels_table = DATA_PTR(labels_wrapper);
int j; int j;
@ -7899,7 +7896,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
} }
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
VALUE obj = ptr[i]; VALUE obj = RARRAY_AREF(body, i);
if (SYMBOL_P(obj)) { if (SYMBOL_P(obj)) {
rb_event_flag_t event; rb_event_flag_t event;

3
gc.c
View File

@ -1955,9 +1955,8 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protect
#if GC_DEBUG_STRESS_TO_CLASS #if GC_DEBUG_STRESS_TO_CLASS
if (UNLIKELY(stress_to_class)) { if (UNLIKELY(stress_to_class)) {
long i, cnt = RARRAY_LEN(stress_to_class); long i, cnt = RARRAY_LEN(stress_to_class);
const VALUE *ptr = RARRAY_CONST_PTR(stress_to_class);
for (i = 0; i < cnt; ++i) { for (i = 0; i < cnt; ++i) {
if (klass == ptr[i]) rb_memerror(); if (klass == RARRAY_AREF(stress_to_class, i)) rb_memerror();
} }
} }
#endif #endif

View File

@ -775,19 +775,17 @@ random_load(VALUE obj, VALUE dump)
rb_random_t *rnd = get_rnd(obj); rb_random_t *rnd = get_rnd(obj);
struct MT *mt = &rnd->mt; struct MT *mt = &rnd->mt;
VALUE state, left = INT2FIX(1), seed = INT2FIX(0); VALUE state, left = INT2FIX(1), seed = INT2FIX(0);
const VALUE *ary;
unsigned long x; unsigned long x;
rb_check_copyable(obj, dump); rb_check_copyable(obj, dump);
Check_Type(dump, T_ARRAY); Check_Type(dump, T_ARRAY);
ary = RARRAY_CONST_PTR(dump);
switch (RARRAY_LEN(dump)) { switch (RARRAY_LEN(dump)) {
case 3: case 3:
seed = ary[2]; seed = RARRAY_AREF(dump, 2);
case 2: case 2:
left = ary[1]; left = RARRAY_AREF(dump, 1);
case 1: case 1:
state = ary[0]; state = RARRAY_AREF(dump, 0);
break; break;
default: default:
rb_raise(rb_eArgError, "wrong dump data"); rb_raise(rb_eArgError, "wrong dump data");

View File

@ -3091,9 +3091,9 @@ rb_thread_to_s(VALUE thread)
if (!target_th->first_func && target_th->first_proc) { if (!target_th->first_func && target_th->first_proc) {
VALUE loc = rb_proc_location(target_th->first_proc); VALUE loc = rb_proc_location(target_th->first_proc);
if (!NIL_P(loc)) { if (!NIL_P(loc)) {
const VALUE *ptr = RARRAY_CONST_PTR(loc); rb_str_catf(str, "@%"PRIsVALUE":%"PRIsVALUE,
rb_str_catf(str, "@%"PRIsVALUE":%"PRIsVALUE, ptr[0], ptr[1]); RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1));
rb_gc_force_recycle(loc); rb_gc_force_recycle(loc);
} }
} }
rb_str_catf(str, " %s>", status); rb_str_catf(str, " %s>", status);

View File

@ -1615,18 +1615,17 @@ native_set_thread_name(rb_thread_t *th)
SET_CURRENT_THREAD_NAME(RSTRING_PTR(loc)); SET_CURRENT_THREAD_NAME(RSTRING_PTR(loc));
} }
else if (!NIL_P(loc = rb_proc_location(th->first_proc))) { else if (!NIL_P(loc = rb_proc_location(th->first_proc))) {
const VALUE *ptr = RARRAY_CONST_PTR(loc); /* [ String, Integer ] */
char *name, *p; char *name, *p;
char buf[16]; char buf[16];
size_t len; size_t len;
int n; int n;
name = RSTRING_PTR(ptr[0]); name = RSTRING_PTR(RARRAY_AREF(loc, 0));
p = strrchr(name, '/'); /* show only the basename of the path. */ p = strrchr(name, '/'); /* show only the basename of the path. */
if (p && p[1]) if (p && p[1])
name = p + 1; name = p + 1;
n = snprintf(buf, sizeof(buf), "%s:%d", name, NUM2INT(ptr[1])); n = snprintf(buf, sizeof(buf), "%s:%d", name, NUM2INT(RARRAY_AREF(loc, 1)));
rb_gc_force_recycle(loc); /* acts as a GC guard, too */ rb_gc_force_recycle(loc); /* acts as a GC guard, too */
len = (size_t)n; len = (size_t)n;