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