improve efficiency of _glob_to_re

erikj/disable_catchup_to_hq
Richard van der Hoff 2021-04-19 18:56:53 +01:00
parent bf4ad8070e
commit edac710bc0
1 changed files with 2 additions and 1 deletions

View File

@ -230,7 +230,8 @@ def _glob_to_re(glob: str, word_boundary: bool) -> Pattern:
if IS_GLOB.search(glob):
r = re.escape(glob)
r = r.replace(r"\*", ".*?")
# replace 1 or more repeats of `\*` with `.*?`
r = re.sub(r"(\\\*)+", ".*?", r)
r = r.replace(r"\?", ".")
# handle [abc], [a-z] and [!a-z] style ranges.