diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 6d47fef371c..382c7344961 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1246,10 +1246,24 @@ class WM_OT_doc_view_manual(Operator): if verbose: print("online manual check for: '%s'... " % rna_id) from fnmatch import fnmatchcase + + import re + # Match characters that have a special meaning to `fnmatch`. + # If any of these characters are used we must let `fnmatch` run it's own matching logic. + # However, in most cases a literal prefix is used making it considerably faster to do a + # simple `startswith` check before performing a full match, see #104581. + re_match_non_speical = re.compile("^[^?*\\[]+").match + # XXX, for some reason all RNA ID's are stored lowercase # Adding case into all ID's isn't worth the hassle so force lowercase. rna_id = rna_id.lower() for pattern, url_suffix in url_mapping: + + # Simple optimization, makes a big difference (over 50x speedup). + non_special_end = re_match_non_speical(pattern).end() + if non_special_end > 0 and (not rna_id.startswith(pattern[:non_special_end])): + continue + if fnmatchcase(rna_id, pattern): if verbose: print(" match found: '%s' --> '%s'" % (pattern, url_suffix))