introducing regex caching mechanism

This commit is contained in:
Miroslav Stampar
2010-05-21 14:42:59 +00:00
parent 14cab8527e
commit 5d5ebd49b6
4 changed files with 24 additions and 10 deletions

View File

@@ -70,6 +70,8 @@ from lib.core.settings import SQLITE_ALIASES
from lib.core.settings import ACCESS_ALIASES
from lib.core.settings import FIREBIRD_ALIASES
__compiledRegularExpressions = {}
def paramToDict(place, parameters=None):
"""
Split the parameters into names and values, check if these parameters
@@ -1222,3 +1224,11 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
return predictedCharset, otherCharset
else:
return None, originalTable
def getCompiledRegex(regex):
if regex in __compiledRegularExpressions:
return __compiledRegularExpressions[regex]
else:
retVal = re.compile(regex)
__compiledRegularExpressions[regex] = retVal
return retVal