Skip to content

Commit 2f95c1d

Browse files
Merge pull request #319 from JuliaArrays/functional-index-performance
Improve performance of recent function-index
2 parents 5228630 + c26988e commit 2f95c1d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "6.0.17"
3+
version = "6.0.18"
44

55
[deps]
66
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"

src/indexing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,16 @@ to_index(x::LinearIndices, i::AbstractArray{Bool}) = LogicalIndex{Int}(i)
242242
@inline to_index(x, i::NDIndex) = Tuple(i)
243243
@inline to_index(x, i::AbstractArray{<:AbstractCartesianIndex}) = i
244244
@inline function to_index(x, i::Base.Fix2{<:Union{typeof(<),typeof(isless)},<:Union{Base.BitInteger,StaticInt}})
245-
offset1(x):min(_sub1(canonicalize(i.x)), static_lastindex(x))
245+
static_first(x):min(_sub1(canonicalize(i.x)), static_last(x))
246246
end
247247
@inline function to_index(x, i::Base.Fix2{typeof(<=),<:Union{Base.BitInteger,StaticInt}})
248-
offset1(x):min(canonicalize(i.x), static_lastindex(x))
248+
static_first(x):min(canonicalize(i.x), static_last(x))
249249
end
250250
@inline function to_index(x, i::Base.Fix2{typeof(>=),<:Union{Base.BitInteger,StaticInt}})
251-
max(canonicalize(i.x), offset1(x)):static_lastindex(x)
251+
max(canonicalize(i.x), static_first(x)):static_last(x)
252252
end
253253
@inline function to_index(x, i::Base.Fix2{typeof(>),<:Union{Base.BitInteger,StaticInt}})
254-
max(_add1(canonicalize(i.x)), offset1(x)):static_lastindex(x)
254+
max(_add1(canonicalize(i.x)), static_first(x)):static_last(x)
255255
end
256256
# integer indexing
257257
to_index(x, i::AbstractArray{<:Integer}) = i

0 commit comments

Comments
 (0)