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

ruby-changes:38698

From: normal <ko1@a...>
Date: Fri, 5 Jun 2015 07:12:41 +0900 (JST)
Subject: [ruby-changes:38698] normal:r50779 (trunk): io.c: reduce size of :wait_*able code paths

normal	2015-06-05 07:11:19 +0900 (Fri, 05 Jun 2015)

  New Revision: 50779

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

  Log:
    io.c: reduce size of :wait_*able code paths
    
    * io.c (sym_wait_readable, sym_wait_writable): declare
      (io_getpartial): use sym_wait_readable
      (io_write_nonblock): use sym_wait_writable
      (Init_IO): initialize sym_wait_*able
    
    On 32-bit x86:
    
       text    data     bss     dec     hex filename
     121003      56     252  121311   1d9df io.o
     121035      56     252  121343   1d9ff io.o.orig

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50778)
+++ ChangeLog	(revision 50779)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun  5 07:05:58 2015  Eric Wong  <e@8...>
+
+	* io.c (sym_wait_readable, sym_wait_writable): declare
+	  (io_getpartial): use sym_wait_readable
+	  (io_write_nonblock): use sym_wait_writable
+	  (Init_IO): initialize sym_wait_*able
+
 Fri Jun  5 06:43:00 2015  Eric Wong  <e@8...>
 
 	* doc/extension.rdoc: note rb_get_kwargs changes keywords_hash
Index: io.c
===================================================================
--- io.c	(revision 50778)
+++ io.c	(revision 50779)
@@ -176,6 +176,7 @@ static ID id_write, id_read, id_getc, id https://github.com/ruby/ruby/blob/trunk/io.c#L176
 static VALUE sym_mode, sym_perm, sym_extenc, sym_intenc, sym_encoding, sym_open_args;
 static VALUE sym_textmode, sym_binmode, sym_autoclose;
 static VALUE sym_SET, sym_CUR, sym_END;
+static VALUE sym_wait_readable, sym_wait_writable;
 #ifdef SEEK_DATA
 static VALUE sym_DATA;
 #endif
@@ -2523,7 +2524,7 @@ io_getpartial(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/io.c#L2524
                 goto again;
             if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN)) {
                 if (no_exception)
-                    return ID2SYM(rb_intern("wait_readable"));
+                    return sym_wait_readable;
                 else
 		    rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "read would block");
             }
@@ -2717,7 +2718,7 @@ io_write_nonblock(VALUE io, VALUE str, i https://github.com/ruby/ruby/blob/trunk/io.c#L2718
     if (n == -1) {
         if (errno == EWOULDBLOCK || errno == EAGAIN) {
 	    if (no_exception) {
-		return ID2SYM(rb_intern("wait_writable"));
+		return sym_wait_writable;
 	    }
 	    else {
 		rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "write would block");
@@ -12445,4 +12446,6 @@ Init_IO(void) https://github.com/ruby/ruby/blob/trunk/io.c#L12446
 #ifdef SEEK_HOLE
     sym_HOLE = ID2SYM(rb_intern("HOLE"));
 #endif
+    sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
+    sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
 }

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

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