Skip to content

how to wrap a large alternation of literals in word boundary assertions and have it be fast? #890

Answered by BurntSushi
Guillermogsjc asked this question in Q&A
Discussion options

You must be logged in to vote

I've turned this into a feature request in #891.

And... regarding PERFORMANCE documentation here

there is no problem with using non-greedy matching or having lots of alternations in your regex

this previously stated regex would be in the set of "no problem" ?

Yes. But that doesn't mean it gets the Aho-Corasick optimization. The section you're quoting is really written relative to backtracking engines. Namely, a backtracking engine will (absent other optimizations) try each alternate one after the other. This will wind up being slower than even the slowest regex engine in this crate (the PikeVM).

I am being somewhat hand wavy here. Being precise here without concrete examples in front …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Guillermogsjc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants