improve speed if just last line changed

This commit is contained in:
chrys87 2016-07-19 13:37:51 +02:00 committed by GitHub
parent 2c4ed4cb2d
commit 05f254e823

View File

@ -66,7 +66,12 @@ class screen():
environment['screenData']['newContentText'] != '':
environment['screenData']['newDelta'] = environment['screenData']['newContentText']
else:
diff = difflib.ndiff(" ".join(environment['screenData']['oldContentText'].split(' ')), " ".join(environment['screenData']['newContentText'].split(' ')))
diffStart = 0
lastLine = len(environment['screenData']['newDelta']) - environment['screenData']['columns']
if environment['screenData']['newDelta'][:lastLine] == environment['screenData']['newDelta'][:lastLine]:
diffStart = lastLine + 1
diff = difflib.ndiff(" ".join(environment['screenData']['oldContentText'][diffStart:].split(' ')),\
" ".join(environment['screenData']['newContentText'][diffStart:].split(' ')))
environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ '))
return environment