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

ruby-changes:5592

From: matz <ko1@a...>
Date: Wed, 11 Jun 2008 23:54:43 +0900 (JST)
Subject: [ruby-changes:5592] Ruby:r17098 (trunk): * io.c (io_fread): bypass buffered read if reading buffer is empty.

matz	2008-06-11 23:54:23 +0900 (Wed, 11 Jun 2008)

  New Revision: 17098

  Modified files:
    trunk/ChangeLog
    trunk/io.c

  Log:
    * io.c (io_fread): bypass buffered read if reading buffer is empty.
    
    * io.c (remain_size): do not add extra one byte.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17098&r2=17097&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=17098&r2=17097&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17097)
+++ ChangeLog	(revision 17098)
@@ -1,3 +1,9 @@
+Wed Jun 11 23:33:13 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (io_fread): bypass buffered read if reading buffer is empty.
+
+	* io.c (remain_size): do not add extra one byte.
+
 Wed Jun 11 12:15:17 2008  Tanaka Akira  <akr@f...>
 
 	* bootstraptest/runner.rb (assert_normal_exit): hide stderr output
Index: io.c
===================================================================
--- io.c	(revision 17097)
+++ io.c	(revision 17098)
@@ -1298,6 +1298,20 @@
     long n = len;
     int c;
 
+    if (READ_DATA_PENDING(fptr) == 0) {
+	while (n > 0) {
+	    c = rb_read_internal(fptr->fd, RSTRING_PTR(str)+offset, n);
+	    if (c == 0) break;
+	    if (c < 0) {
+		rb_sys_fail(fptr->path);
+	    }
+	    offset += c;
+	    if ((n -= c) <= 0) break;
+	    rb_thread_wait_fd(fptr->fd);
+	}
+	return len - n;
+    }
+
     while (n > 0) {
 	c = read_buffered_data(RSTRING_PTR(str)+offset, n, fptr);
 	if (c > 0) {
@@ -1347,7 +1361,7 @@
 	io_fflush(fptr);
 	pos = lseek(fptr->fd, 0, SEEK_CUR);
 	if (st.st_size >= pos && pos >= 0) {
-	    siz += st.st_size - pos + 1;
+	    siz += st.st_size - pos;
 	    if (siz > LONG_MAX) {
 		rb_raise(rb_eIOError, "file too big for single read");
 	    }

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

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