typelevel / typelevel/cats-parse
alternate design for voiding
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 245
- Forks
- 51
- Avg merge
- 3h 20m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Parser0.parseMut and Parser.State, especially the existing capturing flag, then inspect how a Void parser would delegate parsing. Check the available benchmarks to determine whether a separate parseMutVoid path improves performance while preserving parsing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100