Commit dcf38e8
FEAT: Performance improvement for &Array + scalar and scalar + &Array
* The new implementation avoids cloning the elements twice, and it
avoids iterating over the elements twice. (The old implementation
called `.to_owned()` followed by the arithmetic operation, while the
new implementation clones the elements and performs the arithmetic
operation in the same iteration.)
On my machine, this change improves the performance for both
contiguous and discontiguous arrays. (`scalar_add_1/2` go from ~530
ns/iter to ~380 ns/iter, and `scalar_add_strided_1/2` go from ~1540
ns/iter to ~1420 ns/iter.)
(Other changes to impl applicability removed from this commit.)
Co-authored-by: bluss <bluss@users.noreply.github.com>1 parent 52ca234 commit dcf38e8
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
0 commit comments