mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-15 22:41:38 +00:00
docs: kdoc: micro-optimize KernRe
Switch KernRe::add_regex() to a try..except block to avoid looking up each regex twice. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
@@ -29,12 +29,10 @@ class KernRe:
|
||||
"""
|
||||
Adds a new regex or re-use it from the cache.
|
||||
"""
|
||||
|
||||
if string in re_cache:
|
||||
try:
|
||||
self.regex = re_cache[string]
|
||||
else:
|
||||
except KeyError:
|
||||
self.regex = re.compile(string, flags=flags)
|
||||
|
||||
if self.cache:
|
||||
re_cache[string] = self.regex
|
||||
|
||||
|
||||
Reference in New Issue
Block a user