-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enable precompilation for common Parsers routines (#148)
* Re-enable precompilation for common Parsers routines * enable precompile * add compat for SnoopPrecompile * fix compat
- Loading branch information
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
function _precompile_() | ||
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing | ||
precompile(Tuple{typeof(Parsers.parse), Type{Int64}, String}) | ||
precompile(Tuple{typeof(Parsers.parse), Type{Float64}, String}) | ||
precompile(Tuple{typeof(Parsers.parse), Type{Date}, String}) | ||
using SnoopPrecompile | ||
|
||
@precompile_setup 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) | ||
@precompile_all_calls 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 | ||
_precompile_() |
38615bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
38615bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/71615
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: