Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: micro-optimize KernRe

Rework _add_regex() to avoid doing the lookup twice for the (hopefully
common) cache-hit case.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250703184403.274408-3-corbet@lwn.net

+2 -5
+2 -5
scripts/lib/kdoc/kdoc_re.py
··· 29 29 """ 30 30 Adds a new regex or re-use it from the cache. 31 31 """ 32 - 33 - if string in re_cache: 34 - self.regex = re_cache[string] 35 - else: 32 + self.regex = re_cache.get(string, None) 33 + if not self.regex: 36 34 self.regex = re.compile(string, flags=flags) 37 - 38 35 if self.cache: 39 36 re_cache[string] = self.regex 40 37