diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-09-16 15:21:16 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-09-17 00:31:04 +1200 |
commit | f75009c1222621836b2340bbb5f4d4274972ccb4 (patch) | |
tree | 99b7e93e14d649c8783a6333e39427624d924972 /io.c | |
parent | 68b5f14d536c1a81c63412a9f3701380c9bc116c (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.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -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 |