Improve regexp performance

This commit is contained in:
Alexandre Dulaunoy 2015-02-01 13:04:27 +01:00
parent 65f283253e
commit 9ba1adc8f4

View file

@ -15,11 +15,14 @@ import OpenSSL
cert = None cert = None
certstring = "" certstring = ""
certtag = re.compile('^\s+Certificate\s*$')
certtagend = re.compile('^\S+')
for l in fileinput.input(): for l in fileinput.input():
if re.match('^\s+Certificate\s*$', l): if certtag.match(l):
cert = True cert = True
continue continue
elif re.match('^\S+', l): elif certtagend.match(l):
cert = None cert = None
if (cert is True): if (cert is True):