[前][次][番号順一覧][スレッド一覧]

ruby-changes:33761

From: tadf <ko1@a...>
Date: Tue, 6 May 2014 18:37:27 +0900 (JST)
Subject: [ruby-changes:33761] tadf:r45842 (trunk): * io.c (io_{read, write}_nonblock): use rb_get_kwargs instead of

tadf	2014-05-06 18:37:24 +0900 (Tue, 06 May 2014)

  New Revision: 45842

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45842

  Log:
    * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of
      rb_hash_aref.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45841)
+++ ChangeLog	(revision 45842)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue May  6 18:33:12 2014  Tadayoshi Funaba  <tadf@d...>
+
+	* io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of
+	  rb_hash_aref.
+
 Tue May  6 18:03:05 2014  Tanaka Akira  <akr@f...>
 
 	* lib/time.rb (Time.make_time): Argument validation code moved from
Index: io.c
===================================================================
--- io.c	(revision 45841)
+++ io.c	(revision 45842)
@@ -2615,6 +2615,19 @@ io_readpartial(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/io.c#L2615
     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, https://github.com/ruby/ruby/blob/trunk/io.c#L2688
 
     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 *ar https://github.com/ruby/ruby/blob/trunk/io.c#L2803
 
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]