diff --git a/array.c b/array.c index bf120a450a..2a944d2d75 100644 --- a/array.c +++ b/array.c @@ -5228,11 +5228,9 @@ static int yield_indexed_values(const VALUE values, const long r, const long *const p) { const VALUE result = rb_ary_new2(r); - VALUE *const result_array = RARRAY_PTR(result); - const VALUE *const values_array = RARRAY_CONST_PTR(values); long i; - for (i = 0; i < r; i++) result_array[i] = values_array[p[i]]; + for (i = 0; i < r; i++) RARRAY_ASET(result, i, RARRAY_AREF(values, p[i])); ARY_SET_LEN(result, r); rb_yield(result); return !RBASIC(values)->klass; diff --git a/enum.c b/enum.c index ce7d0102aa..0cecb7d746 100644 --- a/enum.c +++ b/enum.c @@ -1440,7 +1440,7 @@ nmin_filter(struct nmin_data *data) #undef GETPTR #undef SWAP - data->limit = RARRAY_PTR(data->buf)[store_index*eltsize]; /* the last pivot */ + data->limit = RARRAY_AREF(data->buf, store_index*eltsize); /* the last pivot */ data->curlen = data->n; rb_ary_resize(data->buf, data->n * eltsize); } @@ -1518,18 +1518,22 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary) result = data.buf; if (by) { long i; - ruby_qsort(RARRAY_PTR(result), - RARRAY_LEN(result)/2, - sizeof(VALUE)*2, - data.cmpfunc, (void *)&data); - for (i=1; i