From 782dba32b5534ffaa5727a762a4c628bdac32331 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 19 Oct 2013 07:16:22 +0000 Subject: util: minor cleanup to favor rb_io_get_io This makes our code slightly smaller on Ruby 1.9+ --- ext/sleepy_penguin/extconf.rb | 1 + ext/sleepy_penguin/util.c | 4 ++-- 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); } -- cgit v1.2.3-24-ge0c7