kgio RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH 1/3] tryopen: remove RARRAY_PTR usage in init
@ 2013-09-25 19:43 Eric Wong
  2013-09-25 19:43 ` [PATCH 2/3] read_write: remove the rest of RARRAY_PTR usage Eric Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Eric Wong @ 2013-09-25 19:43 UTC (permalink / raw)
  To: kgio

From: Eric Wong <e@yhbt.net>

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



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH 1/3] tryopen: remove RARRAY_PTR usage in init
@ 2013-09-25 19:42 Eric Wong
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Wong @ 2013-09-25 19:42 UTC (permalink / raw)
  To: kgio

From: Eric Wong <e@yhbt.net>

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



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-09-26  3:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-25 19:43 [PATCH 1/3] tryopen: remove RARRAY_PTR usage in init Eric Wong
2013-09-25 19:43 ` [PATCH 2/3] read_write: remove the rest of RARRAY_PTR usage Eric Wong
2013-09-25 19:43 ` [PATCH 3/3] my_writev: stylistic fixes Eric Wong
2013-09-25 19:44 ` [PATCH 1/3] tryopen: remove RARRAY_PTR usage in init Eric Wong
2013-09-25 21:37 ` Aeon
2013-09-25 22:00   ` Eric Wong
2013-09-26  3:02     ` Aeon
  -- strict thread matches above, loose matches on Subject: below --
2013-09-25 19:42 Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/kgio.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).