Skip to content

Unnecessary cursor restores #226

@ojwb

Description

@ojwb

I noticed that we're generating unnecessary cursor restores for or in some cases.

The simplest example is probably:

'a' or 'b'

K_needed() reports that this can change the cursor - that's true (because 'a' moves the cursor if it matches) but for generating the or itself what actually matters is if a clause can move the cursor and fail. That's still possible, e.g. we do need to restore the cursor if the first clause fails here:

('a' 'a') or 'b'

However there are a lot of common cases that can't change the cursor on failure - e.g. an or clause which is a single literal string or grouping.

We should also be checking this per-clause (currently we restore after every clause or after none).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions