Skip to content

Commit

Permalink
use Compat.@inline
Browse files Browse the repository at this point in the history
  • Loading branch information
tiemvanderdeure committed Dec 30, 2024
1 parent 2a446da commit 445469e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.10.8"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Future = "9fa8497b-333b-5362-9e8d-4d0656e87820"
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
Expand All @@ -24,6 +25,7 @@ CategoricalArraysSentinelArraysExt = "SentinelArrays"
CategoricalArraysStructTypesExt = "StructTypes"

[compat]
Compat = "3.37"
DataAPI = "1.6"
JSON = "0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21"
JSON3 = "1.1.2"
Expand Down
7 changes: 3 additions & 4 deletions src/recode.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Compat
const = isequal

"""
Expand Down Expand Up @@ -49,8 +50,6 @@ A user defined type could override this method to define an appropriate test fun
@inline recode_in(x, collection::Set) = x in collection
@inline recode_in(x, collection) = any(x y for y in collection)

@inline findfirstrecode(x, recode_from) = findfirst(y -> isequal(x, y) || recode_in(x,y), recode_from)

optimize_pair(pair::Pair) = pair
optimize_pair(pair::Pair{<:AbstractArray}) = Set(pair.first) => pair.second

Expand All @@ -71,7 +70,7 @@ function _recode!(dest::AbstractArray{T}, src::AbstractArray, default, pairs) wh
@inbounds for i in eachindex(dest, src)
x = src[i]

j = findfirstrecode(x, recode_from)
j = Compat.@inline findfirst(y -> isequal(x, y) || recode_in(x,y), recode_from)
if !isnothing(j)
dest[i] = recode_to[j]
@goto nextitem
Expand Down Expand Up @@ -121,7 +120,7 @@ function _recode!(dest::CategoricalArray{T, <:Any, R}, src::AbstractArray, defau
@inbounds for i in eachindex(drefs, src)
x = src[i]

j = findfirstrecode(x, recode_from)
j = Compat.@inline findfirst(y -> isequal(x, y) || recode_in(x,y), recode_from)
if !isnothing(j)
drefs[i] = dupvals ? pairmap[j] : j
@goto nextitem
Expand Down

0 comments on commit 445469e

Please sign in to comment.