Skip to content

optimize occurrence? #176

@Kreijstal

Description

@Kreijstal
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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions