BlockPolicy: Compile regex once rather than once per migration item

Regex compilation is often rather expensive and in this case, we can
do it once instad of once per migration item.

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2019-01-07 21:20:36 +00:00
parent c4371b9f58
commit 6c3f8354e5
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

View File

@ -929,6 +929,8 @@ class BuildDependsPolicy(BasePolicy):
class BlockPolicy(BasePolicy):
BLOCK_HINT_REGEX = re.compile('^(un)?(block-?.*)$')
def __init__(self, options, suite_info):
super().__init__('block', options, suite_info,
{SuiteClass.PRIMARY_SOURCE_SUITE, SuiteClass.ADDITIONAL_SOURCE_SUITE})
@ -966,7 +968,7 @@ class BlockPolicy(BasePolicy):
shints = self.hints.search(package=src)
mismatches = False
r = re.compile('^(un)?(block-?.*)$')
r = self.BLOCK_HINT_REGEX
for hint in shints:
m = r.match(hint.type)
if m: