Skip to content

Commit fe22190

Browse files
committed
Simplify Deserialization
1 parent 749215c commit fe22190

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

src/serialization.jl

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,41 +53,32 @@ function recover(x::Vector)
5353
for i in 1:fc
5454
ft = fieldtype(T, i)
5555
fn = String(fieldname(T, i))
56-
if fn == "customisable_result"
57-
xsi = customisable_result_recover(fields[fn])
56+
xsi = if fn == "customisable_result"
57+
customisable_result_recover(fields[fn])
58+
elseif ft <: get(SUPPORTED_TYPES, nameof(ft), Union{})
59+
recover(fields[fn])
5860
elseif fn in (
5961
"setup_prehook", "teardown_posthook", "sample_result", "prehook", "posthook"
6062
)
61-
xsi = BenchmarkTools._nothing_func
62-
elseif ft <: get(SUPPORTED_TYPES, nameof(ft), Union{})
63-
xsi = recover(fields[fn])
64-
else
65-
xsi = if fn == "evals_set" && !haskey(fields, fn)
66-
false
67-
elseif fn in ("seconds", "overhead", "time_tolerance", "memory_tolerance") &&
68-
fields[fn] === nothing
69-
# JSON spec doesn't support Inf
70-
# These fields should all be >= 0, so we can ignore -Inf case
71-
typemax(ft)
72-
elseif fn == "enable_customisable_func"
73-
if !haskey(fields, fn)
74-
:FALSE
75-
else
76-
Symbol(fields[fn])
77-
end
78-
elseif fn in (
79-
"run_customisable_func_only",
80-
"customisable_gcsample",
81-
"setup_prehook",
82-
"teardown_posthook",
83-
"sample_result",
84-
"prehook",
85-
"posthook",
86-
) && !haskey(fields, fn)
87-
getfield(BenchmarkTools.DEFAULT_PARAMETERS, Symbol(fn))
63+
getfield(BenchmarkTools.DEFAULT_PARAMETERS, Symbol(fn))
64+
elseif fn == "evals_set" && !haskey(fields, fn)
65+
false
66+
elseif fn in ("seconds", "overhead", "time_tolerance", "memory_tolerance") &&
67+
fields[fn] === nothing
68+
# JSON spec doesn't support Inf
69+
# These fields should all be >= 0, so we can ignore -Inf case
70+
typemax(ft)
71+
elseif fn == "enable_customisable_func"
72+
if !haskey(fields, fn)
73+
:FALSE
8874
else
89-
convert(ft, fields[fn])
75+
Symbol(fields[fn])
9076
end
77+
elseif fn in ("run_customisable_func_only", "customisable_gcsample") &&
78+
!haskey(fields, fn)
79+
getfield(BenchmarkTools.DEFAULT_PARAMETERS, Symbol(fn))
80+
else
81+
convert(ft, fields[fn])
9182
end
9283
if T == BenchmarkGroup && xsi isa Dict
9384
for (k, v) in copy(xsi)

0 commit comments

Comments
 (0)