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

Reorder epsilon transitions #145

Merged
merged 6 commits into from
Nov 26, 2024
Merged

Reorder epsilon transitions #145

merged 6 commits into from
Nov 26, 2024

Conversation

nitely
Copy link
Owner

@nitely nitely commented Nov 24, 2024

Follow up #129

Reorder the epsilon transitions to be evaluated after the matchable node: @[matchable_node_idx, epsilon_transition_idx].

It helps avoiding pointless capts evaluation on regex with alternations: (foo|bar|...). Currently capts are evaluated for all alternations, even if only one matches. Note (foo|bar|...) translates to (foo)|(bar)|... internally to remove epsilon transition states, although all capts refer to the same capt node.

This improves #138 somewhat when using findAll (contains uses the no-capts optimization so no changes there).

This branch:

time nim c -r --threads:off -d:danger tests/test_bug/testbug.nim
compiled
2000
ok

real    0m7.232s
user    0m7.194s
sys     0m0.037s

Master:

time nim c -r --threads:off -d:danger tests/test_bug/testbug.nim
compiled
2000
ok

real    0m19.415s
user    0m20.467s
sys     0m0.270s

@nitely nitely merged commit c64d7e1 into master Nov 26, 2024
2 checks passed
@nitely nitely deleted the transitions_2 branch November 26, 2024 14:18
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