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

Optimisation: Only check disambiguating preconditions once #123

Open
jakobnissen opened this issue Jul 19, 2023 · 0 comments
Open

Optimisation: Only check disambiguating preconditions once #123

jakobnissen opened this issue Jul 19, 2023 · 0 comments

Comments

@jakobnissen
Copy link
Member

In Automa v1, the following code:

machine = let
    a = precond!(onenter!(re"XY", :a), :c)
    b = precond!(onenter!(re"XZ", :b), :c; bool=false)
    compile(a | b)
end;

Does not create an ambiguous NFA and thus compiles perfectly fine. However, the precondition :c is needlessly checked twice: First to check if it's true when entering a, then to check if it's false when entering b.

This needs to be optimised: When Automa detects that there are two edges which are only disambiguated by a precondition, emit code along the lines of this pseudocode

if byte in $(intersection(edge1, edge2))
    if $(precond)
        @goto a
    else
        @goto a
    end
else if byte in [ other edges... ]
[ ... ]
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

No branches or pull requests

1 participant