-
Couldn't load subscription status.
- Fork 25.6k
Enhance regex performance with duplicate wildcards #98176
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
Enhance regex performance with duplicate wildcards #98176
Conversation
| Pinging @elastic/es-core-infra (Team:Core/Infra) |
| Hi @slobodanadamovic, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments on testing more edge cases, but looks good.
| assertFalse(Regex.simpleMatch("fff******ddd", "fffabcdd")); | ||
| } | ||
| | ||
| public void testArbitraryWildcardMatch() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: to cover all branches, consider adding a use case that explicitly use multiple wildcards at the end of the pattern (maybe to the test before this one), and a use case where you have multiple wildcards in multiple locations (like dd**dd**dd).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I've initially randomized the test which should cover dd****, ****dd and dd****dd cases but not dd**dd**dd. I've changed the test to be more explicit in testing all cases in a single run instead of depending on randomization.
…lasticsearch into sa-simple-regex-match
| @elasticmachine update branch |
| Failure seems unrelated and probably temporary: @elasticmachine run elasticsearch-ci/part-1 |
💚 Backport successful
|
This change avoids unnecessary substring allocations and recursion calls when more than two consecutive wildcards (`*`) are detected. Instead skipping and calling a method recursively, we now try to skip all consecutive `*` chars at once.
This change avoids unnecessary substring allocations and recursion calls when more than two consecutive wildcards (`*`) are detected. Instead skipping and calling a method recursively, we now try to skip all consecutive `*` chars at once.
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
This change avoids unnecessary substring allocations and recursion calls when more than two consecutive wildcards (`*`) are detected. Instead skipping and calling a method recursively, we now try to skip all consecutive `*` chars at once. (cherry picked from commit 868df2a)
…98277) This change avoids unnecessary substring allocations and recursion calls when more than two consecutive wildcards (`*`) are detected. Instead skipping and calling a method recursively, we now try to skip all consecutive `*` chars at once.
This change avoids unnecessary substring allocations and recursion calls when more than two consecutive wildcards (
*) are detected. Instead skipping and calling a method recursively, we now try to skip all consecutive*chars at once.