]> thyrsus.com Git - comparator.git/commitdiff
Remove the attempt to skip blank lines, it eliminated hits.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 27 Aug 2003 09:32:52 +0000 (09:32 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 27 Aug 2003 09:32:52 +0000 (09:32 +0000)
shredcompare.py

index 55a0aa8d38e408c3492d35d7e9ebd824a031febc..dd6bccaa7a65a5a8edff56ab8b65d0145d068a24 100755 (executable)
@@ -116,23 +116,13 @@ class ShredTree:
         fp = open(file)
         lines = map(self.__smash_whitespace, fp.readlines())
         fp.close()
-        for i in range(len(lines)):
+        for i in range(len(lines)-shredsize):
             if self.__is_line_relevant(lines[i]):
                 m = md5.new()
-                need = self.shredsize
-                j = 0
-                try:
-                    while need > 0:
-                        if i + j >= len(lines):
-                            raise EOFError
-                        if self.__is_line_relevant(lines[i+j]):
-                            m.update(lines[i+j])
-                            need -= 1
-                        j += 1
-                    # Merging shreds into a dict automatically suppresses dups.
-                    self.shreds[m.digest()] = Shred(file, i, i + j)
-                except EOFError:
-                    pass
+                for j in range(self.shredsize):
+                    m.update(lines[i+j])
+                # Merging shreds into a dict automatically suppresses duplicates.
+                self.shreds[m.digest()] = Shred(file, i, i + self.shredsize)
     def __eligible(self, file):
         "Is a file eligible for comparison?"
         return filter(lambda x: file.endswith(x), ('.c','h','.y','.l','.txt'))