Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip more validation #101

Merged
merged 3 commits into from
Jan 25, 2025
Merged

Conversation

lukemassa
Copy link
Contributor

@lukemassa lukemassa commented Jan 24, 2025

What

Right now, the code skips validating the end of the pattern in MatchUnvalidated() if it finds that pattern has not matched. However, if we get to the end of the name and there is still pattern that is not "zero length", we don't need to validate that either.

Also add some unit tests to make sure we are skipping validation when we can.

Why

Speed up the code a bit by skipping more unnecessary validation.

Tests

I added a unit test specifically to see what errors are being detected whether validate is set to true or false.

When those tests are run on main, they show a single error:

    doublestar_test.go:304: #2. Unvalidated error of Match(`a[`, `a`) = syntax error in pattern want <nil>

This is capturing the fact that we got to the end of the name, had matched the whole way, but were unnecessarily doing additional validation instead of immediately returning false.

@lukemassa lukemassa changed the title Additional validation skip Skip more validation Jan 24, 2025
@bmatcuk
Copy link
Owner

bmatcuk commented Jan 25, 2025

Looks good, thanks!

@bmatcuk bmatcuk merged commit b707fe4 into bmatcuk:master Jan 25, 2025
2 checks passed
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.

2 participants