-
Notifications
You must be signed in to change notification settings - Fork 316
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
Specialize TakeWhileRef fold #884
base: master
Are you sure you want to change the base?
Specialize TakeWhileRef fold #884
Conversation
Specialize TakeWhileRef fold using fold_while logic
@Owen-CH-Leung I'm just curious about why you closed this. I did not look into the details.
|
Opps just wrong click. Yeah I was trying to use the |
let acc = init; | ||
let original_iter = self.iter.clone(); | ||
|
||
let result = self.iter.clone().fold_while(acc, |acc, x| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not clone it a second time.
I think the design |
I don't think we are open of changing the API (see #710). Plus, as I did not play much with About testing, we currently have a |
#755
This PR introduces a custom fold method for
TakeWhileRef
. The optimization hinges on thefold_while
logic:Benchmark Results:
Default fold: time: [53.963 ns 54.083 ns 54.209 ns]
Custom fold: time: [53.210 ns 53.359 ns 53.511 ns]