File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1245,7 +1245,8 @@ macro_rules! iterator {
1245
1245
P : FnMut ( Self :: Item ) -> bool ,
1246
1246
{
1247
1247
// The addition might panic on overflow
1248
- let n = self . len( ) ;
1248
+ // Use the len of the slice to hint optimizer to remove result index bounds check.
1249
+ let n = make_slice!( self . ptr, self . end) . len( ) ;
1249
1250
self . try_fold( 0 , move |i, x| {
1250
1251
if predicate( x) { Err ( i) }
1251
1252
else { Ok ( i + 1 ) }
@@ -1263,7 +1264,8 @@ macro_rules! iterator {
1263
1264
{
1264
1265
// No need for an overflow check here, because `ExactSizeIterator`
1265
1266
// implies that the number of elements fits into a `usize`.
1266
- let n = self . len( ) ;
1267
+ // Use the len of the slice to hint optimizer to remove result index bounds check.
1268
+ let n = make_slice!( self . ptr, self . end) . len( ) ;
1267
1269
self . try_rfold( n, move |i, x| {
1268
1270
let i = i - 1 ;
1269
1271
if predicate( x) { Err ( i) }
You can’t perform that action at this time.
0 commit comments