Skip to content

Commit 55ef5db

Browse files
emmtararslan
authored andcommitted
Simplify expression (#37)
Expression in `unsafe_getindex` is simpler and more understandable. However `@code_native` produces the same code (on Linux, x64) so there is no resulting optimization.
1 parent 6dc6f60 commit 55ef5db

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/definitions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ struct Frequencies{T<:Number} <: AbstractVector{T}
411411
end
412412

413413
unsafe_getindex(x::Frequencies, i::Int) =
414-
(i-1+ifelse(i <= x.n_nonnegative, 0, -x.n))*x.multiplier
414+
(i-1-ifelse(i <= x.n_nonnegative, 0, x.n))*x.multiplier
415415
@inline function Base.getindex(x::Frequencies, i::Int)
416416
@boundscheck Base.checkbounds(x, i)
417417
unsafe_getindex(x, i)

0 commit comments

Comments
 (0)