summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-16 15:21:16 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-17 00:31:04 +1200
commitf75009c1222621836b2340bbb5f4d4274972ccb4 (patch)
tree99b7e93e14d649c8783a6333e39427624d924972 /io.c
parent68b5f14d536c1a81c63412a9f3701380c9bc116c (diff)
Prefer to use `prep_io` for temporary IO instances.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3550
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/io.c b/io.c
index b615aca8c1..b970244e1e 100644
--- a/io.c
+++ b/io.c
@@ -216,6 +216,7 @@ static VALUE sym_HOLE;
#endif
static VALUE rb_io_initialize(int argc, VALUE *argv, VALUE io);
+static VALUE prep_io(int fd, int fmode, VALUE klass, const char *path);
struct argf {
VALUE filename, current_file;
@@ -1295,20 +1296,10 @@ rb_io_wait(VALUE io, VALUE events, VALUE timeout) {
}
}
-VALUE
-rb_io_from_fd(int f)
+static VALUE
+rb_io_from_fd(int fd)
{
- VALUE io = rb_obj_alloc(rb_cIO);
- VALUE argv[] = {RB_INT2NUM(f)};
-
- rb_io_initialize(1, argv, io);
-
- rb_io_t *fptr;
- RB_IO_POINTER(io, fptr);
-
- fptr->mode |= FMODE_PREP;
-
- return io;
+ return prep_io(fd, FMODE_PREP, rb_cIO, NULL);
}
int