From e0d3b3cbe90b47facf0e67036429502ad8f99c49 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 25 Sep 2013 19:20:11 +0000 Subject: tryopen: remove RARRAY_PTR usage in init This is trivially non-performance-critical, and can only help with advanced GCs in Ruby 2.1.0 and Rubinius --- ext/kgio/tryopen.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ext/kgio/tryopen.c b/ext/kgio/tryopen.c index 5fa6ada..902c745 100644 --- a/ext/kgio/tryopen.c +++ b/ext/kgio/tryopen.c @@ -135,8 +135,7 @@ void init_kgio_tryopen(void) VALUE mPipeMethods = rb_const_get(mKgio, rb_intern("PipeMethods")); VALUE cFile; VALUE tmp; - VALUE *ptr; - long len; + long i, len; id_path = rb_intern("path"); id_for_fd = rb_intern("for_fd"); @@ -161,15 +160,15 @@ void init_kgio_tryopen(void) errno2sym = st_init_numtable(); tmp = rb_funcall(rb_mErrno, rb_intern("constants"), 0); - ptr = RARRAY_PTR(tmp); len = RARRAY_LEN(tmp); - for (; --len >= 0; ptr++) { + for (i = 0; i < len; i++) { VALUE error; + VALUE err = rb_ary_entry(tmp, i); ID const_id; - switch (TYPE(*ptr)) { - case T_SYMBOL: const_id = SYM2ID(*ptr); break; - case T_STRING: const_id = rb_intern(RSTRING_PTR(*ptr)); break; + switch (TYPE(err)) { + case T_SYMBOL: const_id = SYM2ID(err); break; + case T_STRING: const_id = rb_intern(RSTRING_PTR(err)); break; default: rb_bug("constant not a symbol or string"); } -- cgit v1.2.3-24-ge0c7