From 2142287c8696f5c8b1ca8e68c557ff61ab921f8e Mon Sep 17 00:00:00 2001 From: glass Date: Sun, 4 Nov 2012 02:56:11 +0000 Subject: * lib/fileutils.rb (module FileUtils): repatch [ruby-core:39622] [Feature #5337]. improve performance of FileUtils.compare_stream. [ruby-core:47545] [Feature #7028] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/fileutils.rb | 17 +++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c455ff44a..4e32dfbb2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Nov 4 11:47:39 2012 Masaki Matsushita + + * lib/fileutils.rb (module FileUtils): repatch [ruby-core:39622] + [Feature #5337]. improve performance of FileUtils.compare_stream. + [ruby-core:47545] [Feature #7028] + Sun Nov 4 11:27:54 2012 Masaki Matsushita * array.c (recursive_equal): fix to return true when self and other diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 67cc79f02f..3d74eac385 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -894,16 +894,13 @@ public # 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 -- cgit v1.2.3