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 `Interleave[Shortest]::fold` #849

Closed Philippe-Cholet closed 7 months ago

Philippe-Cholet commented 7 months ago

Related to #755

cargo bench --bench specializations "interleave(_shortest)?/fold"

interleave/fold            [2.1749 µs 2.1782 µs 2.1817 µs]
                           [754.64 ns 757.16 ns 760.51 ns]
                           [-66.092% -65.545% -65.107%]

interleave_shortest/fold   [1.6414 µs 1.6460 µs 1.6511 µs]
                           [412.05 ns 413.60 ns 415.41 ns]
                           [-74.904% -74.580% -74.173%]
Philippe-Cholet commented 7 months ago

They could surely be a bit more similar (in another PR) at least the names. I'm pretty sure that fuse the iterators in the shortest-variant would be a breaking change for unfused iterators though.