-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use fold
instead of for_each
?
#781
Comments
Well, apart from Before I close this, do you know why? |
I would tweak this one slightly:
If the folder is something like Last people looked into it, threading the passing of a |
Thanks for the detailled precision. |
#780 (comment) by jswrenn
Bold is mine as I wonder if we are using
for_each
(convenient) at multiple places instead offold
.Current
for_each
uses:Itertools::{counts, partition_map, join}
min_set_impl
GroupingMap::{aggregate, collect}
into_group_map
k_smallest
(There is also
Itertools::foreach
but this one is okay.)Why do I care? While benchmarking a new
MapForGrouping::fold
, I found out thatsome_slice_iter::for_each
does not delegate tofold
(default behavior) and is not optimized * (justwhile let Some(x) = self.next() { f(x); }
) whilesome_slice_iter::fold
is optimized (which is useful to see benchmark improvements of specializingfold
methods of our adaptors by delegating to the inner iterator).*: The
for_each
has a comment: "We override the default implementation, which usestry_fold
, because this simple implementation generates less LLVM IR and is faster to compile."The text was updated successfully, but these errors were encountered: