From 05f254e82309c575e89ece53a8d81ccf5118f0dc Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 19 Jul 2016 13:37:51 +0200 Subject: [PATCH] improve speed if just last line changed --- src/fenrir-package/screen/linux.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index da32662c..9737a622 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -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