about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-19 07:16:22 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-19 07:16:22 +0000
commit782dba32b5534ffaa5727a762a4c628bdac32331 (patch)
tree5540b534d17dabb19d8f2186d23cdb39b4aff44b
parent23447e63e64753223768d8481eb3c98f1c933bdf (diff)
downloadsleepy_penguin-782dba32b5534ffaa5727a762a4c628bdac32331.tar.gz
This makes our code slightly smaller on Ruby 1.9+
-rw-r--r--ext/sleepy_penguin/extconf.rb1
-rw-r--r--ext/sleepy_penguin/util.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/sleepy_penguin/extconf.rb b/ext/sleepy_penguin/extconf.rb
index 0e6977a..3a6152b 100644
--- a/ext/sleepy_penguin/extconf.rb
+++ b/ext/sleepy_penguin/extconf.rb
@@ -25,4 +25,5 @@ have_func('rb_thread_io_blocking_region')
 have_func('rb_thread_fd_close')
 have_func('rb_update_max_fd')
 have_func('rb_fd_fix_cloexec')
+have_func('rb_io_get_io')
 create_makefile('sleepy_penguin_ext')
diff --git a/ext/sleepy_penguin/util.c b/ext/sleepy_penguin/util.c
index 717a099..9d2123f 100644
--- a/ext/sleepy_penguin/util.c
+++ b/ext/sleepy_penguin/util.c
@@ -100,7 +100,7 @@ int rb_sp_io_closed(VALUE io)
         case T_FILE:
                 break;
         default:
-                io = rb_convert_type(io, T_FILE, "IO", "to_io");
+                io = rb_io_get_io(io);
         }
 
         return my_rb_io_closed(io);
@@ -110,7 +110,7 @@ int rb_sp_fileno(VALUE io)
 {
         rb_io_t *fptr;
 
-        io = rb_convert_type(io, T_FILE, "IO", "to_io");
+        io = rb_io_get_io(io);
         GetOpenFile(io, fptr);
         return FPTR_TO_FD(fptr);
 }