Skip to content

Infer if backtracking is needed #374

Description

@nielsenko

Problem to Solve

The PathTrie (and hence Router) supports backtracking. You can override it per lookup with the optional backtrack flag, which default true.

But if back-tracking is ever needed is really a function of the registered paths/routes.

The user can choose wrong without knowing - either paying for backtracking when not needed, or fail lookup when backtracking would have found a match.

Proposal

Let PathTrie calculate a _needsBacktracking as paths are added, removed or sub-tries injected.
Use this in place of backtracking.

Use Case

Simplifies the interface for the enduser without leaving performance on the table.

Alternatives

Live with current situation.

Additional context

No response

How experienced are you with this library?

Expert - Experienced and comfortable with using this library in complex projects

Are you interested in working on a PR for this?

  • I want to work on this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions