From 09a2f8678e7eddfc604ca7284fec81e278b774bc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 11 Jun 2023 21:33:26 +0000 Subject: 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. --- ext/raindrops/my_fileno.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ext/raindrops') 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 */ -- cgit v1.2.3-24-ge0c7