Skip to content

Commit 9c3b73f

Browse files
authored
Reduce invalidation by not specializing lastindex/axes1 (#311)
* don't specialize firstindex/lastindex * bump version to v1.12.8 * don't specialize axes1 for IdOffsetRange
1 parent b845230 commit 9c3b73f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "OffsetArrays"
22
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3-
version = "1.12.7"
3+
version = "1.12.8"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/axes.jl

+10-5
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ offset_coerce(::Type{I}, r::AbstractUnitRange) where I<:AbstractUnitRange =
170170
convert(I, r)::I, 0
171171

172172
@inline Base.parent(r::IdOffsetRange) = r.parent
173-
@inline Base.axes(r::IdOffsetRange) = (Base.axes1(r),)
174-
@inline Base.axes1(r::IdOffsetRange) = IdOffsetRange(Base.axes1(r.parent), r.offset)
175-
@inline Base.unsafe_indices(r::IdOffsetRange) = (Base.axes1(r),)
173+
@inline Base.axes(r::IdOffsetRange) = (axes1(r),)
174+
@inline axes1(r::IdOffsetRange) = IdOffsetRange(Base.axes1(r.parent), r.offset)
175+
if VERSION < v"1.8.2"
176+
Base.axes1(r::IdOffsetRange) = axes1(r)
177+
end
178+
@inline Base.unsafe_indices(r::IdOffsetRange) = (axes1(r),)
176179
@inline Base.length(r::IdOffsetRange) = length(r.parent)
177180
@inline Base.isempty(r::IdOffsetRange) = isempty(r.parent)
178181
#= We specialize on reduced_indices to work around cases where the parent axis type doesn't
@@ -188,8 +191,10 @@ end
188191
Base.reduced_index(i::IdOffsetRange) = typeof(i)(first(i):first(i))
189192
# Workaround for #92 on Julia < 1.4
190193
Base.reduced_index(i::IdentityUnitRange{<:IdOffsetRange}) = typeof(i)(first(i):first(i))
191-
for f in [:firstindex, :lastindex]
192-
@eval @inline Base.$f(r::IdOffsetRange) = $f(r.parent) + r.offset
194+
if VERSION < v"1.8.2"
195+
for f in [:firstindex, :lastindex]
196+
@eval @inline Base.$f(r::IdOffsetRange) = $f(r.parent) + r.offset
197+
end
193198
end
194199
for f in [:first, :last]
195200
# coerce the type to deal with values that get promoted on addition (eg. Bool)

0 commit comments

Comments
 (0)