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

alternate design for voiding #379

Open
johnynek opened this issue Feb 13, 2022 · 0 comments
Open

alternate design for voiding #379

johnynek opened this issue Feb 13, 2022 · 0 comments

Comments

@johnynek
Copy link
Collaborator

Currently Parser0 has a private[parse] def parseMut(state: Parser.State): A method. To implement .void we keep track of a mutable var in State and set capturing = false so we can avoid allocation.

An alternate design would be:

private[parse] def parseMut(state: Parser.State): A
private[parse] def parseMutVoid(state: Parser.State): Unit

In this picture, a case class Void(inner: Parser[Any) extends Parser[Unit] would just call parseMutVoid for its parseMut and parseMutVoid. This would potentially do less work since once we convert over to the parseMutVoid we don't check capture again all the way down.

We may or may not have a broad enough set of benchmarks to see a win here, but it may be worth a try.

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