forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#106343 - the8472:slice-iter-fold, r=scottmcm
optimize slice::Iter::fold Fixes 2 of 4 cases from rust-lang#106288 ``` OLD: test slice::fold_to_last ... bench: 248 ns/iter (+/- 3) NEW: test slice::fold_to_last ... bench: 0 ns/iter (+/- 0) ```
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// ignore-debug: the debug assertions get in the way | ||
// compile-flags: -O | ||
// min-llvm-version: 16 | ||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: @slice_fold_to_last | ||
#[no_mangle] | ||
pub fn slice_fold_to_last(slice: &[i32]) -> Option<&i32> { | ||
// CHECK-NOT: loop | ||
// CHECK-NOT: br | ||
// CHECK-NOT: call | ||
// CHECK: ret | ||
slice.iter().fold(None, |_, i| Some(i)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters