From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.kgio.general Subject: [PATCH 1/3] tryopen: remove RARRAY_PTR usage in init Date: Wed, 25 Sep 2013 19:42:37 +0000 Message-ID: <1380138159-5350-1-git-send-email-normalperson@yhbt.net> References: <1380138159-5350-1-git-send-email-normalperson@yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1380138179 6701 80.91.229.3 (25 Sep 2013 19:42:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Sep 2013 19:42:59 +0000 (UTC) To: kgio@librelist.org Original-X-From: kgio@librelist.org Wed Sep 25 21:43:02 2013 Return-path: Envelope-to: gclrkg-kgio@m.gmane.org In-Reply-To: <1380138159-5350-1-git-send-email-normalperson@yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: kgio@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.kgio.general:233 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VOuzG-0008Pv-1v for gclrkg-kgio@m.gmane.org; Wed, 25 Sep 2013 21:43:02 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 134F27511F for ; Wed, 25 Sep 2013 19:53:39 +0000 (UTC) From: Eric Wong 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"); } -- 1.8.3.2.701.g8c4e4ec