[前][次][番号順一覧][スレッド一覧]

ruby-changes:21248

From: ayumin <ko1@a...>
Date: Mon, 19 Sep 2011 19:34:40 +0900 (JST)
Subject: [ruby-changes:21248] ayumin:r33297 (trunk): * lib/fileutils.rb (module FileUtils): improve performance of

ayumin	2011-09-19 19:34:30 +0900 (Mon, 19 Sep 2011)

  New Revision: 33297

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33297

  Log:
    * lib/fileutils.rb (module FileUtils): improve performance of
      FileUtils.compare_stream. a patch by Masaki Matsushita.
      [Feature #5337] [ruby-core:39622]

  Modified files:
    trunk/ChangeLog
    trunk/lib/fileutils.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33296)
+++ ChangeLog	(revision 33297)
@@ -1,3 +1,9 @@
+Mon Sep 19 18:55:51 2011  Ayumu AIZAWA  <ayumu.aizawa@g...>
+
+	* 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@g...>
 
 	* test/-ext-/old_thread_select/test_old_thread_select.rb:
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 33296)
+++ lib/fileutils.rb	(revision 33297)
@@ -823,16 +823,13 @@
   #
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]