Speed up colorless diff

This commit is contained in:
Behdad Esfahbod 2012-01-21 19:40:30 -05:00
parent 1e58df6034
commit 3e86feb54c
1 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,12 @@ class FancyDiffer:
@staticmethod @staticmethod
def diff_lines (l1, l2, colors=Colors.Null): def diff_lines (l1, l2, colors=Colors.Null):
# Easy without colors
if colors == Colors.Null:
if l1 == l2:
return [' ', l1]
return ['-', l1, '+', l2]
ss = [FancyDiffer.diff_regex.sub (r'\1\n\2\n', l).splitlines (True) for l in (l1, l2)] ss = [FancyDiffer.diff_regex.sub (r'\1\n\2\n', l).splitlines (True) for l in (l1, l2)]
oo = ["",""] oo = ["",""]
st = [False, False] st = [False, False]