-
Notifications
You must be signed in to change notification settings - Fork 242
Open
Labels
enhancementNew feature or requestNew feature or request
Description
This is a feature request for engine optimization.
Repro: https://3v4l.org/JKn6D/rfc#vgit.master_jit
Such dummy regexes like (a|b|...|z) are very common for language grammars or routing.
The repro shows massive speedup (from 3.4 ms to 0.82 ms). According regex101.com the speedup is 865 vs. 93 steps only.
The engine should detect shared prefix/subpattern in alternative branch like (ab?c|ab?d) and optimize it into (ab?(?:c|d)).
Why we need this optimization? Consider these patterns:
- non-consequent shared prefix - ex.
(ab?c|x|ab?d)!=(ab?(?:c|d)|x) - subpatterns with capturing groups - ex.
((a)b|((a)c)!=((a)(?:b|c))
such usecases need internal optimization support as they cannot be optimized outside the engine.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request