File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -933,6 +933,7 @@ impl<A: Array> Extend<A::Item> for ArrayVec<A> {
933
933
unsafe {
934
934
let len = self . len ( ) ;
935
935
let mut ptr = self . as_mut_ptr ( ) . offset ( len as isize ) ;
936
+ let end_ptr = ptr. offset ( take as isize ) ;
936
937
// Keep the length in a separate variable, write it back on scope
937
938
// exit. To help the compiler with alias analysis and stuff.
938
939
// We update the length to handle panic in the iteration of the
@@ -944,10 +945,16 @@ impl<A: Array> Extend<A::Item> for ArrayVec<A> {
944
945
* * self_len = Index :: from ( len) ;
945
946
}
946
947
} ;
947
- for elt in iter. into_iter ( ) . take ( take) {
948
- ptr:: write ( ptr, elt) ;
949
- ptr = ptr. offset ( 1 ) ;
950
- guard. data += 1 ;
948
+ let mut iter = iter. into_iter ( ) ;
949
+ loop {
950
+ if ptr == end_ptr { break ; }
951
+ if let Some ( elt) = iter. next ( ) {
952
+ ptr:: write ( ptr, elt) ;
953
+ ptr = ptr. offset ( 1 ) ;
954
+ guard. data += 1 ;
955
+ } else {
956
+ break ;
957
+ }
951
958
}
952
959
}
953
960
}
You can’t perform that action at this time.
0 commit comments