From a55a06c47da413f78ef7b4ae480d2c3172763f60 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 20 May 2018 11:45:21 +0200 Subject: menuconfig: Use lower() instead of re.IGNORECASE in search This gets rid of some slight input jerkiness while inputting e.g. '.*debug' on my machine (though the '.*' is redundant there), due to faster matching. The '.*' probably has bad interactions with re.search(), which matches anywhere in the string. A plain "debug" matches about 70% faster, though it's fast enough to feel instant anyway. --- menuconfig.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index 296701f..9055d5b 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1443,8 +1443,15 @@ def _jump_to_dialog(): prev_s = s try: - regex_searches = [re.compile(regex, re.IGNORECASE).search - for regex in s.split()] + # We could use re.IGNORECASE here instead of lower(), but this + # is noticeably less jerky while inputting regexes like + # '.*debug$' (though the '.*' is redundant there). Those + # probably have bad interactions with re.search(), which + # matches anywhere in the string. + # + # It's not horrible either way. Just a bit smoother. + regex_searches = [re.compile(regex).search + for regex in s.lower().split()] # No exception thrown, so the regexes are okay bad_re = None @@ -1456,8 +1463,9 @@ def _jump_to_dialog(): for search in regex_searches: # Does the regex match either the symbol name or the # prompt (if any)? - if not (search(node.item.name) or - (node.prompt and search(node.prompt[0]))): + if not (search(node.item.name.lower()) or + (node.prompt and + search(node.prompt[0].lower()))): # Give up on the first regex that doesn't match, to # speed things up a bit when multiple regexes are -- cgit v1.2.3