diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-20 11:45:21 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-20 12:02:45 +0200 |
| commit | a55a06c47da413f78ef7b4ae480d2c3172763f60 (patch) | |
| tree | 5efcbeb7c60a7df64f9905280bc303e8b13fa4f4 | |
| parent | 73fea2bc6f817523fdfcfc9cecdc3aaa5e9f2494 (diff) | |
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.
| -rwxr-xr-x | menuconfig.py | 16 |
1 files 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 |
