|
1 |
| -function _precompile_() |
2 |
| - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing |
3 |
| - precompile(Tuple{typeof(Parsers.parse), Type{Int64}, String}) |
4 |
| - precompile(Tuple{typeof(Parsers.parse), Type{Float64}, String}) |
5 |
| - precompile(Tuple{typeof(Parsers.parse), Type{Date}, String}) |
| 1 | +using SnoopPrecompile |
| 2 | + |
| 3 | +@precompile_setup begin |
| 4 | + # Putting some things in `setup` can reduce the size of the |
| 5 | + # precompile file and potentially make loading faster. |
| 6 | + options = Parsers.Options() |
| 7 | + pos = 1 |
| 8 | + val = "123" |
| 9 | + len = length(val) |
| 10 | + @precompile_all_calls begin |
| 11 | + # all calls in this block will be precompiled, regardless of whether |
| 12 | + # they belong to your package or not (on Julia 1.8 and higher) |
| 13 | + for T in (String, Int32, Int64, Float64, BigFloat, Dates.Date, Dates.DateTime, Dates.Time, Bool) |
| 14 | + for buf in (codeunits(val), Vector(codeunits(val))) |
| 15 | + Parsers.xparse(T, buf, pos, len, options) |
| 16 | + Parsers.xparse(T, buf, pos, len, options, Any) |
| 17 | + end |
| 18 | + end |
| 19 | + |
| 20 | + for T in (Int32, Int64, Float64, BigFloat, Dates.Date, Dates.DateTime, Dates.Time, Bool) |
| 21 | + for buf in (val, SubString(val, 1:3), Vector(codeunits(val)), view(Vector(codeunits(val)), 1:3)) |
| 22 | + try |
| 23 | + Parsers.parse(T, buf, options) |
| 24 | + catch |
| 25 | + end |
| 26 | + Parsers.tryparse(T, buf, options) |
| 27 | + end |
| 28 | + end |
| 29 | + end |
6 | 30 | end
|
7 |
| -_precompile_() |
|
0 commit comments