Skip to content

Commit f6be2fb

Browse files
iamed2mbauman
authored andcommitted
Fix performance regression by updating findfirst calls for 0.7 (#137)
1 parent 702623f commit f6be2fb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ julia 0.6
22
IntervalSets 0.1
33
IterTools
44
RangeArrays
5-
Compat 0.33.0
5+
Compat 0.61.0

src/core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ end
258258
function axisdim(::Type{AxisArray{T,N,D,Ax}}, ::Type{<:Axis{name,S} where S}) where {T,N,D,Ax,name}
259259
isa(name, Int) && return name <= N ? name : error("axis $name greater than array dimensionality $N")
260260
names = axisnames(Ax)
261-
idx = findfirst(names, name)
262-
idx == 0 && error("axis $name not found in array axes $names")
261+
idx = Compat.findfirst(isequal(name), names)
262+
idx === nothing && error("axis $name not found in array axes $names")
263263
idx
264264
end
265265

src/indexing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ end
284284

285285
# Categorical axes may be indexed by their elements
286286
function axisindexes(::Type{Categorical}, ax::AbstractVector, idx)
287-
i = findfirst(ax, idx)
288-
i == 0 && throw(ArgumentError("index $idx not found"))
287+
i = Compat.findfirst(isequal(idx), ax)
288+
i === nothing && throw(ArgumentError("index $idx not found"))
289289
i
290290
end
291291
function axisindexes(::Type{Categorical}, ax::AbstractVector, idx::Value)
292292
val = idx.val
293-
i = findfirst(ax, val)
294-
i == 0 && throw(ArgumentError("index $val not found"))
293+
i = Compat.findfirst(isequal(val), ax)
294+
i === nothing && throw(ArgumentError("index $val not found"))
295295
i
296296
end
297297
# Categorical axes may be indexed by a vector of their elements

0 commit comments

Comments
 (0)