about summary refs log tree commit homepage
path: root/ext/raindrops/my_fileno.h
diff options
context:
space:
mode:
authorEric Wong <bofh@yhbt.net>2023-06-11 21:33:26 +0000
committerEric Wong <bofh@yhbt.net>2023-06-26 09:16:38 +0000
commit09a2f8678e7eddfc604ca7284fec81e278b774bc (patch)
treeade724584f5b36bde4c947969054770d19a252d9 /ext/raindrops/my_fileno.h
parenta8dfec2568830241a27fce10014b6151a7a47813 (diff)
downloadraindrops-09a2f8678e7eddfc604ca7284fec81e278b774bc.tar.gz
my_fileno: use rb_io_check_closed for Ruby <3.1
This is less code and hopefully smaller binaries.
`rb_io_check_closed' has been in Ruby since the pre-CVS of
decades ago, and it doesn't matter if it's removed or not
in the future since Ruby 3.1+ doesn't see this code path
and calls `rb_io_descriptor' directly.
Diffstat (limited to 'ext/raindrops/my_fileno.h')
-rw-r--r--ext/raindrops/my_fileno.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/ext/raindrops/my_fileno.h b/ext/raindrops/my_fileno.h
index 646f31b..3a0100f 100644
--- a/ext/raindrops/my_fileno.h
+++ b/ext/raindrops/my_fileno.h
@@ -9,9 +9,8 @@ static int my_fileno(VALUE io)
         rb_io_t *fptr;
 
         GetOpenFile(io, fptr);
+        rb_io_check_closed(fptr);
 
-        if (fptr->fd < 0)
-                rb_raise(rb_eIOError, "closed stream");
         return fptr->fd;
 }
 #endif /* Ruby <3.1 !HAVE_RB_IO_DESCRIPTOR */