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: if none of the resolvers need capture information capturing is unnecessary #1

Open
masklinn opened this issue Jun 16, 2024 · 0 comments

Comments

@masklinn
Copy link
Collaborator

masklinn commented Jun 16, 2024

Probably not useful for the initial release but something to consider for later. This could be done three ways:

  • add that information as a flag to the repl from construction
  • pre-check the resolvers at extraction
  • capture lazily instead of eagerly

The first two complicate resolution as it means resolve has to be duplicated to handle the None/Replacement cases separately, the latter probably just means constructing the capture once using OnceCell (/ LazyCell) instead of using a Capture parameter.

Later clarification for myself: this is about calling re.capture during extraction e.g.

let c = re.captures(ua)?;

::None and ::Replacement resolver variants have no need for the capture data, although that means resolve would need to be faillible. Then again, we could just expect/unwrap since by definition matching should only yield matching regexes, so captures should always succeed.

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