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.
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_whilelogic: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]