about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2013-09-25 19:20:11 +0000
committerEric Wong <normalperson@yhbt.net>2013-09-25 19:41:27 +0000
commite0d3b3cbe90b47facf0e67036429502ad8f99c49 (patch)
tree266649590e50b8eda43808d6cb6e5f9489ae494b
parent98bbc4bd1fda4aa7fddcb57db659bb3e507238e7 (diff)
downloadkgio-e0d3b3cbe90b47facf0e67036429502ad8f99c49.tar.gz
This is trivially non-performance-critical, and can only
help with advanced GCs in Ruby 2.1.0 and Rubinius
-rw-r--r--ext/kgio/tryopen.c13
1 files 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");
                 }