From 4ed087b0db4c11d743762615e2d3759b8c2aaf66 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 10 Oct 2018 04:17:01 +0000 Subject: revisit `RARRAY_PTR()`. * array.c (yield_indexed_values): use RARRAY_AREF/ASET instead of using RARRAY_PTR(). * enum.c (nmin_filter): ditto. * proc.c (rb_sym_to_proc): ditto. * enum.c (rb_nmin_run): use RARRAY_PTR_USE() instead of RARRAY_PTR(). It is safe because they don't make new referecen from an array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'array.c') 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; -- cgit v1.2.3