Closed m4rw3r closed 8 years ago
Aww, did you decide this wasn't feasible?
It is merged in a local copy of master which I have not yet pushed, along with #18. Currently I am polishing some things and updating all the doctests to use parse_only
instead of Input::new
and unwrap
. So it is not gone at all, just that the feature itself is done :)
The performance is promising, equal or slightly better performance in most cases except for in very small benchmarks.
It is merged in a local copy of master which I have not yet pushed,
Ah, gotcha. I'm just so used to seeing issues automatically closed by Github when the corresponding commit is pushed to master. When I didn't see the "X closed by Y" message, I just assumed that meant that it couldn't be done.
The performance is promising
Great!
@shepmaster You can try it out now if you want, 0.2.0 is out :)
Implementing
Iterator::size_hint
will enable more efficient allocation for the containers. According to profiling a lot of time is spent allocating and reallocating in some situations, a bettersize_hint
would improve performance.count
should yield(n, Some(n))
since it will always result inn
elements on success.many1
andsep_by1
should yield(1, None)
since they have no upper boundmany
,many_till
andsep_by
can use the default value of(0, None)
It might also be feasible to implement a combinator which is a hybrid of count and many, where specifying both a lower and upper bound is possible. This would make it a lot more efficient to allocate some parts (and by using monadic composition it can even reserve space for a certain known number of elements which was specified earlier in the message).
Spec for bounded
many
n
items should be emitted unless the range is lacking an upper boundsize_hint
based on the range should be providedFromIterator
valueEND_OF_INPUT
and input.len is 0.TODO
bounded::many
specBoundedRange
traitbounded::many
implsiter::Iter
count
many
many1
sep_by
sep_by1
bounded::many_till
iter::IterTill
(many_till
)bounded::skip_many