From 0332d471961098cb9e62d19d9497ac0b69db04c5 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Mon, 8 Jul 2024 23:30:07 +0200 Subject: [PATCH] inline some functions to improve perf with huge number of types --- src/DynamicSumTypes.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DynamicSumTypes.jl b/src/DynamicSumTypes.jl index 3965713..e4ed51e 100644 --- a/src/DynamicSumTypes.jl +++ b/src/DynamicSumTypes.jl @@ -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