]> thyrsus.com Git - comparator.git/commitdiff
Fixed range-merging bug.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 25 Aug 2003 09:42:08 +0000 (09:42 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 25 Aug 2003 09:42:08 +0000 (09:42 +0000)
shredcompare.py

index 0af1970b6b9357815e9ff2ffa826826c5f9fa42e..b4263c6bd3e2fc3e717455b8f7281479a9448962 100755 (executable)
@@ -137,17 +137,18 @@ def shredcompare(tree1, tree2):
     merge_hit = True
     while merge_hit:
         merge_hit = False
-        for i in range(1,len(matches)):
-            j = len(matches) - i
+        j = len(matches) - 1
+        while j > 0:
             this = matches[j]
             last = matches[j-1]
             if last[0].file == this[0].file \
                   and last[1].file==this[1].file \
                    and last[0].start==this[0].start-1:
                 merge_hit = True
-                last[0].end += 1
-                last[1].end +=1
+                last[0].end = this[0].end
+                last[1].end = this[1].end
                 matches = matches[:j] + matches[j+1:]
+            j -= 1
     return matches
 
 def report_time(legend=None):