-
Notifications
You must be signed in to change notification settings - Fork 15
/
precompile.jl
30 lines (28 loc) · 1.13 KB
/
precompile.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using PrecompileTools
@setup_workload begin
# Putting some things in `setup` can reduce the size of the
# precompile file and potentially make loading faster.
options = Parsers.Options()
pos = 1
val = "123"
len = length(val)
@compile_workload begin
# all calls in this block will be precompiled, regardless of whether
# they belong to your package or not (on Julia 1.8 and higher)
for T in (String, Int32, Int64, Float64, BigFloat, Dates.Date, Dates.DateTime, Dates.Time, Bool)
for buf in (codeunits(val), Vector(codeunits(val)))
Parsers.xparse(T, buf, pos, len, options)
Parsers.xparse(T, buf, pos, len, options, Any)
end
end
for T in (Int32, Int64, Float64, BigFloat, Dates.Date, Dates.DateTime, Dates.Time, Bool)
for buf in (val, SubString(val, 1:3), Vector(codeunits(val)), view(Vector(codeunits(val)), 1:3))
try
Parsers.parse(T, buf, options)
catch
end
Parsers.tryparse(T, buf, options)
end
end
end
end