* 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
This commit is contained in:
ayumin 2011-09-19 10:34:30 +00:00
Родитель d4db53a0e0
Коммит 6ec841b2df
2 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -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> Mon Sep 19 18:42:58 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* test/-ext-/old_thread_select/test_old_thread_select.rb: * test/-ext-/old_thread_select/test_old_thread_select.rb:

Просмотреть файл

@ -823,16 +823,13 @@ module FileUtils
# #
def compare_stream(a, b) def compare_stream(a, b)
bsize = fu_stream_blksize(a, b) bsize = fu_stream_blksize(a, b)
sa = sb = nil sa = ""
while sa == sb sb = ""
sa = a.read(bsize) begin
sb = b.read(bsize) a.read(bsize, sa)
unless sa and sb b.read(bsize, sb)
if sa.nil? and sb.nil? return true if sa.empty? && sb.empty?
return true end while sa == sb
end
end
end
false false
end end
module_function :compare_stream module_function :compare_stream