From 9ba1adc8f471490045d739f32b1de6be080abb07 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 1 Feb 2015 13:04:27 +0100 Subject: [PATCH] Improve regexp performance --- bin/x509/pcap-sslcert.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/x509/pcap-sslcert.py b/bin/x509/pcap-sslcert.py index e8188d3..0d9c752 100644 --- a/bin/x509/pcap-sslcert.py +++ b/bin/x509/pcap-sslcert.py @@ -15,11 +15,14 @@ import OpenSSL cert = None certstring = "" +certtag = re.compile('^\s+Certificate\s*$') +certtagend = re.compile('^\S+') + for l in fileinput.input(): - if re.match('^\s+Certificate\s*$', l): + if certtag.match(l): cert = True continue - elif re.match('^\S+', l): + elif certtagend.match(l): cert = None if (cert is True):