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

ruby-changes:30498

From: usa <ko1@a...>
Date: Fri, 16 Aug 2013 11:26:39 +0900 (JST)
Subject: [ruby-changes:30498] usa:r42577 (trunk): * file.c (rb_file_size, rb_file_flock): improve parformance of Winodws.

usa	2013-08-16 11:26:28 +0900 (Fri, 16 Aug 2013)

  New Revision: 42577

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

  Log:
    * file.c (rb_file_size, rb_file_flock): improve parformance of Winodws.
    
    * file.c (rb_file_truncate): removed unnecessary #ifdef.
    
    * test/test_file.rb (TestFile#test_truncate_size): added an assertion
      for File#size.

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/test/ruby/test_file.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42576)
+++ ChangeLog	(revision 42577)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug 16 11:23:35 2013  NAKAMURA Usaku  <usa@r...>
+
+	* file.c (rb_file_size, rb_file_flock): improve parformance of Winodws.
+
+	* file.c (rb_file_truncate): removed unnecessary #ifdef.
+
+	* test/test_file.rb (TestFile#test_truncate_size): added an assertion
+	  for File#size.
+
 Fri Aug 16 10:07:59 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (bigdivrem_single1): Renamed from bigdivrem_single.  Add
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 42576)
+++ test/ruby/test_file.rb	(revision 42577)
@@ -139,6 +139,7 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L139
 
       while size = q1.pop
         assert_equal size, File.size(f.path)
+        assert_equal size, f.size
         q2.push true
       end
     end
Index: file.c
===================================================================
--- file.c	(revision 42576)
+++ file.c	(revision 42577)
@@ -2083,7 +2083,7 @@ rb_file_size(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L2083
 
     GetOpenFile(obj, fptr);
     if (fptr->mode & FMODE_WRITABLE) {
-	rb_io_flush(obj);
+	rb_io_flush_raw(obj, 0);
     }
     if (fstat(fptr->fd, &st) == -1) {
 	rb_sys_fail_path(fptr->pathv);
@@ -4244,11 +4244,7 @@ rb_file_truncate(VALUE obj, VALUE len) https://github.com/ruby/ruby/blob/trunk/file.c#L4244
     if (!(fptr->mode & FMODE_WRITABLE)) {
 	rb_raise(rb_eIOError, "not opened for writing");
     }
-#ifndef _WIN32
-    rb_io_flush(obj);
-#else
     rb_io_flush_raw(obj, 0);
-#endif
 #ifdef HAVE_FTRUNCATE
     if (ftruncate(fptr->fd, pos) < 0)
 	rb_sys_fail_path(fptr->pathv);
@@ -4355,7 +4351,7 @@ rb_file_flock(VALUE obj, VALUE operation https://github.com/ruby/ruby/blob/trunk/file.c#L4351
     op[0] = fptr->fd;
 
     if (fptr->mode & FMODE_WRITABLE) {
-	rb_io_flush(obj);
+	rb_io_flush_raw(obj, 0);
     }
     while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) {
 	switch (errno) {

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

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