From f2e870c9a78a8da0f4e0aa70b613f7857535ae13 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 16 Aug 2013 02:26:28 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ file.c | 8 ++------ test/ruby/test_file.rb | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21033f5b85..41e6f379aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Aug 16 11:23:35 2013 NAKAMURA Usaku + + * 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 * bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Add diff --git a/file.c b/file.c index 3594bbd431..2d7ff32cef 100644 --- a/file.c +++ b/file.c @@ -2083,7 +2083,7 @@ rb_file_size(VALUE obj) 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) 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) 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) { diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 50f101867a..25ad11c64f 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -139,6 +139,7 @@ class TestFile < Test::Unit::TestCase while size = q1.pop assert_equal size, File.size(f.path) + assert_equal size, f.size q2.push true end end