Skip to content

Commit 42c8cf6

Browse files
authored
remove unnecessary broadcasting in firstindex/lastindex (#177)
* remove broadcasting in firstindex/lastindex * version bump to v1.4.3
1 parent 83df130 commit 42c8cf6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.4.2"
3+
version = "1.4.3"
44

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

src/axes.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ offset_coerce(::Type{I}, r::AbstractUnitRange) where I<:AbstractUnitRange =
133133
Base.reduced_index(i::IdOffsetRange) = typeof(i)(first(i):first(i))
134134
# Workaround for #92 on Julia < 1.4
135135
Base.reduced_index(i::IdentityUnitRange{<:IdOffsetRange}) = typeof(i)(first(i):first(i))
136-
for f in [:firstindex, :lastindex]
137-
@eval Base.$f(r::IdOffsetRange) = $f(r.parent) .+ r.offset
136+
for f in [:firstindex, :lastindex, :first, :last]
137+
@eval @inline Base.$f(r::IdOffsetRange) = $f(r.parent) + r.offset
138138
end
139139

140140
@inline function Base.iterate(r::IdOffsetRange)
@@ -148,9 +148,6 @@ end
148148
return (ret[1] + r.offset, ret[2])
149149
end
150150

151-
@inline Base.first(r::IdOffsetRange) = first(r.parent) + r.offset
152-
@inline Base.last(r::IdOffsetRange) = last(r.parent) + r.offset
153-
154151
@propagate_inbounds Base.getindex(r::IdOffsetRange, i::Integer) = r.parent[i - r.offset] + r.offset
155152
@propagate_inbounds function Base.getindex(r::IdOffsetRange, s::AbstractUnitRange{<:Integer})
156153
return r.parent[s .- r.offset] .+ r.offset

0 commit comments

Comments
 (0)