Skip to content

Switch from manual parsing to winnow makes parsing 30% slower #610

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

You must be logged in to vote

I suspect the alts are the biggest problem. Next, I would try to minimuze the use of repeat.

Something like

let allowed_chars = (b'a'..=b'z', b'A'..=b'Z', b'0'..=b'9', b'_');
let component = take_while(1.., allowed_chars);
let non_root = repeat(0.., (b'/', component).map(|()| ());
let root = b'/'.map(|_| ());
alt((non_root, root)).parse(path).map_err(|_| {
    Error::IncorrectType
})

Hmm, was hoping to get rid of that last alt but I think switching to take_while will make a big difference.

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
11 replies
@epage
Comment options

Answer selected by zeenix
@zeenix
Comment options

@zeenix
Comment options

@zeenix
Comment options

@epage
Comment options

Comment options

You must be logged in to vote
3 replies
@epage
Comment options

@zeenix
Comment options

@zeenix
Comment options

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