reduce regex calculation to improve speed
This commit is contained in:
parent
37d1d3f6c5
commit
7ac04d992b
@ -5,6 +5,7 @@
|
|||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from core import debug
|
from core import debug
|
||||||
|
|
||||||
@ -115,8 +116,8 @@ class driver():
|
|||||||
self.env['screenData']['newNegativeDelta'] = ''
|
self.env['screenData']['newNegativeDelta'] = ''
|
||||||
self.env['screenData']['newDelta'] = ''
|
self.env['screenData']['newDelta'] = ''
|
||||||
# changes on the screen
|
# changes on the screen
|
||||||
oldScreenText = self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['oldContentText'])
|
oldScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['oldContentText']))
|
||||||
newScreenText = self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['newContentText'])
|
newScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['newContentText']))
|
||||||
if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \
|
if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \
|
||||||
(self.env['screenData']['newContentText'] != '' ):
|
(self.env['screenData']['newContentText'] != '' ):
|
||||||
if oldScreenText == '' and\
|
if oldScreenText == '' and\
|
||||||
@ -129,15 +130,11 @@ class driver():
|
|||||||
self.env['screenData']['newContentText'][:self.env['screenData']['newCursor']['y']] == self.env['screenData']['oldContentText'][:self.env['screenData']['newCursor']['y']]:
|
self.env['screenData']['newContentText'][:self.env['screenData']['newCursor']['y']] == self.env['screenData']['oldContentText'][:self.env['screenData']['newCursor']['y']]:
|
||||||
diffStart = self.env['screenData']['newCursor']['y'] * self.env['screenData']['columns'] + self.env['screenData']['newCursor']['y']
|
diffStart = self.env['screenData']['newCursor']['y'] * self.env['screenData']['columns'] + self.env['screenData']['newCursor']['y']
|
||||||
oldScreenText = self.env['screenData']['oldContentText'][diffStart:diffStart + self.env['screenData']['columns']]
|
oldScreenText = self.env['screenData']['oldContentText'][diffStart:diffStart + self.env['screenData']['columns']]
|
||||||
oldScreenText = ' '.join(oldScreenText.split(' '))
|
oldScreenText = re.sub(' +',' ',oldScreenText)
|
||||||
print(newScreenText)
|
|
||||||
newScreenText = self.env['screenData']['newContentText'][diffStart:diffStart + self.env['screenData']['columns']]
|
newScreenText = self.env['screenData']['newContentText'][diffStart:diffStart + self.env['screenData']['columns']]
|
||||||
newScreenText = ' '.join(newScreenText.split(' '))
|
newScreenText = re.sub(' +',' ',newScreenText)
|
||||||
print(newScreenText)
|
|
||||||
diff = difflib.ndiff(oldScreenText, newScreenText)
|
diff = difflib.ndiff(oldScreenText, newScreenText)
|
||||||
else:
|
else:
|
||||||
oldScreenText = ' '.join(oldScreenText.split(' '))
|
|
||||||
newScreenText = ' '.join(newScreenText.split(' '))
|
|
||||||
diff = difflib.ndiff(oldScreenText, newScreenText)
|
diff = difflib.ndiff(oldScreenText, newScreenText)
|
||||||
diff = difflib.ndiff( oldScreenText.split('\n'),\
|
diff = difflib.ndiff( oldScreenText.split('\n'),\
|
||||||
newScreenText.split('\n'))
|
newScreenText.split('\n'))
|
||||||
|
Loading…
Reference in New Issue
Block a user