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

optimize occurrence? #176

Open
Kreijstal opened this issue Nov 2, 2022 · 0 comments
Open

optimize occurrence? #176

Kreijstal opened this issue Nov 2, 2022 · 0 comments

Comments

@Kreijstal
Copy link

Kreijstal commented Nov 2, 2022

let n=1;
C.char(',').drop().then(C.string('test').debug('Why is this being executed twice?')).occurrence(n).then(C.char(',')).then(C.string('test')).parse(Streams.ofString(",test,test,test,test"))

the string gets executed n+1 times, however it seems wasteful, when n is for example 0, there is no need to "lookahead".. So it should just look ahead the times it wants to actually parse.
In this toy example, this is irrelevant, however when parsing big files, this can add up significantly...

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