From d85c226f73f5d59e03190ef8f29d316ea33f34e0 Mon Sep 17 00:00:00 2001 From: tadf Date: Tue, 6 May 2014 09:37:24 +0000 Subject: [PATCH] * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of rb_hash_aref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae4da220d5..aef5ff6a31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue May 6 18:33:12 2014 Tadayoshi Funaba + + * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of + rb_hash_aref. + Tue May 6 18:03:05 2014 Tanaka Akira * lib/time.rb (Time.make_time): Argument validation code moved from diff --git a/io.c b/io.c index 3062a5fc3a..533989cb62 100644 --- a/io.c +++ b/io.c @@ -2615,6 +2615,19 @@ io_readpartial(int argc, VALUE *argv, VALUE io) return ret; } +static VALUE +get_kwargs_exception(VALUE opts) +{ + static ID ids[1]; + VALUE except; + + if (!ids[0]) + ids[0] = sym_exception; + + rb_get_kwargs(opts, ids, 0, 1, &except); + return except; +} + /* * call-seq: * ios.read_nonblock(maxlen) -> string @@ -2675,7 +2688,7 @@ io_read_nonblock(int argc, VALUE *argv, VALUE io) rb_scan_args(argc, argv, "11:", NULL, NULL, &opts); - if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception)) + if (!NIL_P(opts) && Qfalse == get_kwargs_exception(opts)) no_exception = 1; ret = io_getpartial(argc, argv, io, 1, no_exception); @@ -2790,7 +2803,7 @@ rb_io_write_nonblock(int argc, VALUE *argv, VALUE io) rb_scan_args(argc, argv, "10:", &str, &opts); - if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception)) + if (!NIL_P(opts) && Qfalse == get_kwargs_exception(opts)) no_exceptions = 1; return io_write_nonblock(io, str, no_exceptions);