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 6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- use std:: cmp;
10
9
use std:: ptr as std_ptr;
11
10
use std:: slice;
12
11
@@ -1917,18 +1916,20 @@ where
1917
1916
F : FnMut ( & mut A , & B ) ,
1918
1917
{
1919
1918
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 ;
1927
1928
}
1928
- return ;
1929
1929
}
1930
1930
}
1931
- // otherwise, fall back to the outer iter
1931
+
1932
+ // Otherwise, fall back to the outer iter
1932
1933
self . zip_mut_with_by_rows ( rhs, f) ;
1933
1934
}
1934
1935
You can’t perform that action at this time.
0 commit comments