rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.69k stars 303 forks source link

Specialize `TakeWhileInclusive::fold` #851

Closed Philippe-Cholet closed 7 months ago

Philippe-Cholet commented 7 months ago

Related to #755

cargo bench --bench specializations "take_while_inclusive/fold"

take_while_inclusive/fold   [556.44 ns 559.37 ns 562.70 ns]
                            [536.51 ns 538.17 ns 539.76 ns]
                            [-6.2459% -4.9270% -3.8918%]

It's not much of a win but try_fold does not show real performance wins on slices and we benchmark on slices. It would perform better on other kind of iterators.