diff options
author | 2025-06-30 09:33:23 -0600 | |
---|---|---|
committer | 2025-06-30 09:56:01 -0600 | |
commit | 09b9297478a3da4d940af8ff8c5f8e27be4990e8 (patch) | |
tree | aa6aafe8842700c1004da8cda70f8a5a392f61c5 /scripts/lib/kdoc/kdoc_re.py | |
parent | docs: kdoc: don't reinvent string.strip() (diff) | |
download | wireguard-linux-09b9297478a3da4d940af8ff8c5f8e27be4990e8.tar.xz wireguard-linux-09b9297478a3da4d940af8ff8c5f8e27be4990e8.zip |
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>
Diffstat (limited to 'scripts/lib/kdoc/kdoc_re.py')
-rw-r--r-- | scripts/lib/kdoc/kdoc_re.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/scripts/lib/kdoc/kdoc_re.py b/scripts/lib/kdoc/kdoc_re.py index e81695b273bf..a467cd2f160b 100644 --- a/scripts/lib/kdoc/kdoc_re.py +++ b/scripts/lib/kdoc/kdoc_re.py @@ -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 |