Skip to content

How to use repeat_till efficiently #561

Answered by epage
Enduriel asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like there are two points of complication

  • You recognized the terminator but don't want to
  • You want parsing to pick back up at the terminator, rather than after it

You could peek your terminator. It will match but not advance input. This means you will recognize only the parse and allow parsing to pick back up at the terminator.

This will clean up the code but I'm unsure if it will affect performance.

Depending on where you land between performance and clean code, repeat_till (especially per char parse) and all of those alts will kill your performance (along with parsing &str instead of &[u8]).

  • If possible, try to use dispatch! as a first pass between all of your token types
  • Try t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Enduriel
Comment options

@epage
Comment options

Answer selected by Enduriel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants