diff options
author | ayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-19 10:34:30 +0000 |
---|---|---|
committer | ayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-19 10:34:30 +0000 |
commit | 6ec841b2df3bcf95180c7d8f6b73d80d7f44d4e6 (patch) | |
tree | f071cae5da119ce9978904494ec3f237a348728f | |
parent | d4db53a0e00f06e44b583156359258aa213fda52 (diff) | |
download | ruby-6ec841b2df3bcf95180c7d8f6b73d80d7f44d4e6.tar.gz |
* lib/fileutils.rb (module FileUtils): improve performance of
FileUtils.compare_stream. a patch by Masaki Matsushita.
[Feature #5337] [ruby-core:39622]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/fileutils.rb | 17 |
2 files changed, 13 insertions, 10 deletions
@@ -1,3 +1,9 @@ +Mon Sep 19 18:55:51 2011 Ayumu AIZAWA <ayumu.aizawa@gmail.com> + + * lib/fileutils.rb (module FileUtils): improve performance of + FileUtils.compare_stream. a patch by Masaki Matsushita. + [Feature #5337] [ruby-core:39622] + Mon Sep 19 18:42:58 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> * test/-ext-/old_thread_select/test_old_thread_select.rb: diff --git a/lib/fileutils.rb b/lib/fileutils.rb index d4213dd0be..168bef7405 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -823,16 +823,13 @@ module FileUtils # def compare_stream(a, b) bsize = fu_stream_blksize(a, b) - sa = sb = nil - while sa == sb - sa = a.read(bsize) - sb = b.read(bsize) - unless sa and sb - if sa.nil? and sb.nil? - return true - end - end - end + sa = "" + sb = "" + begin + a.read(bsize, sa) + b.read(bsize, sb) + return true if sa.empty? && sb.empty? + end while sa == sb false end module_function :compare_stream |