summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-10 04:17:01 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-10 04:17:01 +0000
commit4ed087b0db4c11d743762615e2d3759b8c2aaf66 (patch)
treeb88f05f86e454b1a4a167fe4cb3fdc498c4d6858 /proc.c
parent165b446166c65f4dd905569981d188cc3eee8a17 (diff)
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
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/proc.c b/proc.c
index 4c983244ee..74800e63ca 100644
--- a/proc.c
+++ b/proc.c
@@ -1206,7 +1206,6 @@ rb_sym_to_proc(VALUE sym)
VALUE proc;
long index;
ID id;
- VALUE *aryp;
if (!sym_proc_cache) {
sym_proc_cache = rb_ary_tmp_new(SYM_PROC_CACHE_SIZE * 2);
@@ -1217,14 +1216,13 @@ rb_sym_to_proc(VALUE sym)
id = SYM2ID(sym);
index = (id % SYM_PROC_CACHE_SIZE) << 1;
- aryp = RARRAY_PTR(sym_proc_cache);
- if (aryp[index] == sym) {
- return aryp[index + 1];
+ if (RARRAY_AREF(sym_proc_cache, index) == sym) {
+ return RARRAY_AREF(sym_proc_cache, index + 1);
}
else {
- proc = sym_proc_new(rb_cProc, ID2SYM(id));
- aryp[index] = sym;
- aryp[index + 1] = proc;
+ proc = sym_proc_new(rb_cProc, ID2SYM(id));
+ RARRAY_ASET(sym_proc_cache, index, sym);
+ RARRAY_ASET(sym_proc_cache, index + 1, proc);
return proc;
}
}