-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Slow performance of std::iter::Rev with iterator adapters using std::iter::Iterator::nth() #54054
Copy link
Copy link
Open
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following example shows a benchmark of the iterator adapter
step_by(). Once usingstep_by()directly on the range and once with a redirection viarev().Running this benchmark with the current nightly shows these results:
step_by()makes use ofnth()of the adapted iterator. A range provides an optimized version ofnth(), but by usingrev()we get to use the default implementation ofnth().We should Extend
std::iter::DoubleEndedIteratorto provide a new method maybenth_back()orrnth()with a default implementation which then can get adapted byrev(). Similar to the already existingnext_back(),try_rfold(),rfold()andrfind().Update:
nth_back()has been merged in #56802. Types which have a specializednth()and implementDoubleEndedIteratorare candidates for a specializednth_back(). The following list shows these candidates and their implementation status:nth_backfor ChunksExactMut #63265)