Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0450df8

Browse files
committed
added kb.cache for storing cached results (e.g. kb.cache.regex for storing compiled regular expressions and kb.cache.md5 for storing precalculated MD5 values during '--users --common-prediction' session)
1 parent b798222 commit 0450df8

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/core/common.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676
from lib.core.settings import ACCESS_ALIASES
7777
from lib.core.settings import FIREBIRD_ALIASES
7878

79-
__compiledRegularExpressions = {}
80-
8179
def paramToDict(place, parameters=None):
8280
"""
8381
Split the parameters into names and values, check if these parameters
@@ -1305,14 +1303,11 @@ def getCompiledRegex(regex, *args):
13051303
Returns compiled regular expression and stores it in cache for further
13061304
usage
13071305
"""
1308-
1309-
global __compiledRegularExpressions
1310-
1311-
if (regex, args) in __compiledRegularExpressions:
1312-
return __compiledRegularExpressions[(regex, args)]
1306+
if (regex, args) in kb.cache.regex:
1307+
return kb.cache.regex[(regex, args)]
13131308
else:
13141309
retVal = re.compile(regex, *args)
1315-
__compiledRegularExpressions[(regex, args)] = retVal
1310+
kb.cache.regex[(regex, args)] = retVal
13161311
return retVal
13171312

13181313
def getPartRun():

lib/core/option.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,11 @@ def __setKnowledgeBaseAttributes():
928928

929929
kb.absFilePaths = set()
930930
kb.bannerFp = advancedDict()
931+
932+
kb.cache = advancedDict()
933+
kb.cache.regex = {}
934+
kb.cache.md5 = {}
935+
931936
kb.commonOutputs = None
932937
kb.data = advancedDict()
933938

0 commit comments

Comments
 (0)