Skip to content

Commit

Permalink
inline some functions to improve perf with huge number of types
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Jul 8, 2024
1 parent aaf0c55 commit 0332d47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DynamicSumTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ macro sumtype(typedef)
variants::Union{$(variants...)}
$type(v) = $(branchs(variants, :(return new(v)))...)
end
function DynamicSumTypes.variant(sumt::$type)
@inline function DynamicSumTypes.variant(sumt::$type)
v = DynamicSumTypes.unwrap(sumt)
$(branchs(variants, :(return v))...)
end
function Base.getproperty(sumt::$type, s::Symbol)
@inline function Base.getproperty(sumt::$type, s::Symbol)
v = DynamicSumTypes.unwrap(sumt)
$(branchs(variants, :(return Base.getproperty(v, s)))...)
end
function Base.setproperty!(sumt::$type, s::Symbol, value)
@inline function Base.setproperty!(sumt::$type, s::Symbol, value)
v = DynamicSumTypes.unwrap(sumt)
$(branchs(variants, :(return Base.setproperty!(v, s, value)))...)
end
Expand Down

0 comments on commit 0332d47

Please sign in to comment.