Skip to content

Commit 7aa9ed5

Browse files
committed
simple optimization
1 parent aeba8a4 commit 7aa9ed5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/generic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ julia> rmul!([NaN], 0.0)
280280
```
281281
"""
282282
function rmul!(X::AbstractArray, s::Number)
283+
isone(s) && return X
283284
@simd for I in eachindex(X)
284285
@inbounds X[I] *= s
285286
end
@@ -318,6 +319,7 @@ julia> lmul!(0.0, [Inf])
318319
```
319320
"""
320321
function lmul!(s::Number, X::AbstractArray)
322+
isone(s) && return X
321323
@simd for I in eachindex(X)
322324
@inbounds X[I] = s*X[I]
323325
end

0 commit comments

Comments
 (0)