File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 66// option. This file may not be copied, modified, or distributed
77// except according to those terms.
88
9- use std:: cmp;
109use std:: ptr as std_ptr;
1110use std:: slice;
1211
@@ -1917,18 +1916,20 @@ where
19171916 F : FnMut ( & mut A , & B ) ,
19181917 {
19191918 debug_assert_eq ! ( self . shape( ) , rhs. shape( ) ) ;
1920- if let Some ( self_s) = self . as_slice_mut ( ) {
1921- if let Some ( rhs_s) = rhs. as_slice ( ) {
1922- let len = cmp:: min ( self_s. len ( ) , rhs_s. len ( ) ) ;
1923- let s = & mut self_s[ ..len] ;
1924- let r = & rhs_s[ ..len] ;
1925- for i in 0 ..len {
1926- f ( & mut s[ i] , & r[ i] ) ;
1919+
1920+ // Same shape and order should have same strides
1921+ if self . strides ( ) == rhs. strides ( ) {
1922+ if let Some ( self_s) = self . as_slice_memory_order_mut ( ) {
1923+ if let Some ( rhs_s) = rhs. as_slice_memory_order ( ) {
1924+ for ( s, r) in self_s. iter_mut ( ) . zip ( rhs_s) {
1925+ f ( s, & r) ;
1926+ }
1927+ return ;
19271928 }
1928- return ;
19291929 }
19301930 }
1931- // otherwise, fall back to the outer iter
1931+
1932+ // Otherwise, fall back to the outer iter
19321933 self . zip_mut_with_by_rows ( rhs, f) ;
19331934 }
19341935
You can’t perform that action at this time.
0 commit comments