Skip to content

avoid exponential backtracking for repeated * in glob patterns - #156

Open
jmestwa-coder wants to merge 1 commit into
jaraco:mainfrom
jmestwa-coder:glob-multistar-backtrack
Open

jmestwa-coder wants to merge 1 commit into
jaraco:mainfrom
jmestwa-coder:glob-multistar-backtrack

Conversation

@jmestwa-coder

Copy link
Copy Markdown

Noticed translate_core maps each single * to [^/]* and just concatenates them, so a pattern with several * in one segment like aaa.txt becomes adjacent [^/]* groups that backtrack exponentially against a long non-matching name. Through Path.glob a 10-star pattern on a 40-char entry takes about 16s, doubling per added pair of stars. Commit each interior segment star with an atomic group so matching stays linear. This is a different case from the consecutive ** collapse.

@jmestwa-coder

Copy link
Copy Markdown
Author

gentle ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant