From: Eric S. Raymond Date: Wed, 27 Aug 2003 09:32:52 +0000 (+0000) Subject: Remove the attempt to skip blank lines, it eliminated hits. X-Git-Tag: 1.0~130 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=41df729f844e0a66832ffc7ac0c6fe38f64cb9de;p=comparator.git Remove the attempt to skip blank lines, it eliminated hits. --- diff --git a/shredcompare.py b/shredcompare.py index 55a0aa8..dd6bcca 100755 --- a/shredcompare.py +++ b/shredcompare.py @@ -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'))