mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Compile RecordedUrl regex to improve performance
Minor optimisation.
This commit is contained in:
parent
38d6e4337d
commit
be7048844b
@ -350,6 +350,7 @@ class WarcProxyHandler(warcprox.mitmproxy.MitmProxyHandler):
|
|||||||
# logging better handled elsewhere?
|
# logging better handled elsewhere?
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
RE_MIMETYPE = re.compile(r'[;\s]')
|
||||||
|
|
||||||
class RecordedUrl:
|
class RecordedUrl:
|
||||||
logger = logging.getLogger("warcprox.warcproxy.RecordedUrl")
|
logger = logging.getLogger("warcprox.warcproxy.RecordedUrl")
|
||||||
@ -389,7 +390,7 @@ class RecordedUrl:
|
|||||||
self.mimetype = content_type
|
self.mimetype = content_type
|
||||||
if self.mimetype:
|
if self.mimetype:
|
||||||
# chop off subtype, and ensure there's no whitespace
|
# chop off subtype, and ensure there's no whitespace
|
||||||
self.mimetype = re.split(r'[;\s]', self.mimetype, 2)[0]
|
self.mimetype = RE_MIMETYPE.split(self.mimetype, 2)[0]
|
||||||
|
|
||||||
self.custom_type = custom_type
|
self.custom_type = custom_type
|
||||||
self.status = status
|
self.status = status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user