Don't search for intra-line diffs in really long lines
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2011 20:22:53 +0000 (20:22 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2011 20:22:53 +0000 (20:22 +0000)
Doing so can lead to hangs (or at least really slow execution).

Fixes <http://webkit.org/b/56109> run-webkit-tests sometimes times out on Windows XP Debug
(Tests) after fast/text/large-text-composed-char-dos.html fails (due to PrettyPatch
hanging?)

Reviewed by David Kilzer.

* PrettyPatch/PrettyPatch.rb:
(PrettyPatch.MAXIMUM_INTRALINE_DIFF_LINE_LENGTH): Added this new constant.
(PrettyPatch.DiffSection.initialize): Don't bother looking for intra-line diffs in lines
longer than the maximum length.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80741 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

index a3ad327..8dd2311 100644 (file)
@@ -1,3 +1,20 @@
+2011-03-10  Adam Roben  <aroben@apple.com>
+
+        Don't search for intra-line diffs in really long lines
+
+        Doing so can lead to hangs (or at least really slow execution).
+
+        Fixes <http://webkit.org/b/56109> run-webkit-tests sometimes times out on Windows XP Debug
+        (Tests) after fast/text/large-text-composed-char-dos.html fails (due to PrettyPatch
+        hanging?)
+
+        Reviewed by David Kilzer.
+
+        * PrettyPatch/PrettyPatch.rb:
+        (PrettyPatch.MAXIMUM_INTRALINE_DIFF_LINE_LENGTH): Added this new constant.
+        (PrettyPatch.DiffSection.initialize): Don't bother looking for intra-line diffs in lines
+        longer than the maximum length.
+
 2011-02-25  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Barth.
index edc43c4..8f42ac2 100644 (file)
@@ -70,6 +70,9 @@ private
     START_OF_EXTENT_STRING = "%c" % 0
     END_OF_EXTENT_STRING = "%c" % 1
 
+    # We won't search for intra-line diffs in lines longer than this length, to avoid hangs. See <http://webkit.org/b/56109>.
+    MAXIMUM_INTRALINE_DIFF_LINE_LENGTH = 10000
+
     SMALLEST_EQUAL_OPERATION = 3
 
     OPENSOURCE_TRAC_URL = "http://trac.webkit.org/"
@@ -726,7 +729,10 @@ END
             for change in changes
                 next unless change.first.length == change.last.length
                 for i in (0...change.first.length)
-                    raw_operations = HTMLDiff::DiffBuilder.new(change.first[i].text, change.last[i].text).operations
+                    from_text = change.first[i].text
+                    to_text = change.last[i].text
+                    next if from_text.length > MAXIMUM_INTRALINE_DIFF_LINE_LENGTH or to_text.length > MAXIMUM_INTRALINE_DIFF_LINE_LENGTH
+                    raw_operations = HTMLDiff::DiffBuilder.new(from_text, to_text).operations
                     operations = []
                     back = 0
                     raw_operations.each_with_index do |operation, j|