Skip to content

Commit

Permalink
Add precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Mar 3, 2021
1 parent 20c8c84 commit 6195aba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 57 deletions.
8 changes: 4 additions & 4 deletions src/FileIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ include("registry.jl")
"""
FileIO

# if VERSION >= v"1.4.2" # https://github.com/JuliaLang/julia/pull/35378
# include("precompile.jl")
# _precompile_()
# end
if VERSION >= v"1.4.2" # https://github.com/JuliaLang/julia/pull/35378
include("precompile.jl")
_precompile_()
end

include("deprecated.jl")

Expand Down
69 changes: 16 additions & 53 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,59 +1,22 @@
function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
@assert precompile(Tuple{typeof(detect_bedgraph),IOStream})
@assert precompile(Tuple{typeof(detect_noometiff),IOStream})
@assert precompile(Tuple{typeof(detect_rdata),IOStream})
@assert precompile(Tuple{typeof(detect_rdata_single),IOStream})
@assert precompile(Tuple{typeof(detectwav),IOStream})

@assert precompile(Tuple{typeof(load),File})
@assert precompile(Tuple{typeof(load),Formatted})
@assert precompile(Tuple{typeof(load),String})
@assert precompile(Tuple{typeof(FileIO.load_filename),Formatted,String})
if isdefined(Base, :bodyfunction)
fbody = Base.bodyfunction(which(FileIO.load_filename, (Formatted, String)))
@assert precompile(fbody, (Any, typeof(FileIO.load_filename), Formatted, String))
@assert precompile(fbody, (Any, typeof(FileIO.load_filename), Formatted, String, Vararg{Any,100}))
for f in (detect_rdata, detect_rdata_single, detectwav, detect_bedgraph,
detecttiff, detect_noometiff, detect_ometiff, detectavi,
detecthdf5, detect_stlascii, detect_stlbinary, detect_gadget2)
@assert precompile(f, (IOStream,))
end

@assert precompile(Tuple{typeof(query),String})
@assert precompile(Tuple{typeof(query),IOStream})
@assert precompile(Tuple{typeof(query),IOStream,String})
@assert precompile(Tuple{typeof(query),IOStream,Nothing})

@assert precompile(Tuple{typeof(hasfunction),Function})
@assert precompile(Tuple{typeof(hasmagic),Function})

@assert precompile(Tuple{typeof(applicable_loaders),Type{<:DataFormat}})
@assert precompile(Tuple{typeof(applicable_loaders),Formatted})
@assert precompile(Tuple{typeof(applicable_savers),Type{<:DataFormat}})
@assert precompile(Tuple{typeof(applicable_savers),Formatted})
@assert precompile(Tuple{typeof(add_loader),Type{<:DataFormat},Symbol})
@assert precompile(Tuple{typeof(add_saver),Type{<:DataFormat},Symbol})

@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{10,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{20,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{30,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{32,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{35,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{4,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{6,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{7,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},NTuple{8,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},Tuple{UInt8,UInt8,UInt8}})
@assert precompile(Tuple{typeof(iter_eq),Array{UInt8,1},Tuple{UInt8,UInt8}})

if isdefined(Base, :bodyfunction)
m = which(query, (String,))
f = Base.bodyfunction(m)
@assert precompile(f, (Bool, typeof(query), String))
m = which(load, (String,))
f = Base.bodyfunction(m)
@assert precompile(f, (Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, typeof(load), String))
m = which(load, (Formatted,))
f = Base.bodyfunction(m)
@assert precompile(f, (Any, typeof(load), Formatted))
@assert precompile(f, (Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, typeof(load), File))
for F in (String, IOStream, Formatted)
@assert precompile(query, (F,))
@assert precompile(load, (F,))
@assert precompile(save, (F,Nothing,))
@assert precompile(loadstreaming, (F,))
@assert precompile(savestreaming, (F,))
end

@assert precompile(action, (Symbol,Vector{Union{PkgId, Module}},Symbol,String))
@assert precompile(action, (Symbol,Vector{Union{PkgId, Module}},Symbol,IOStream))
@assert precompile(action, (Symbol,Vector{Union{PkgId, Module}},Formatted))
@assert precompile(loadstreaming, (Function, Any))
@assert precompile(savestreaming, (Function, Any))
@assert precompile(skipmagic, (IOStream,Vector{Vector{UInt8}},))
end

0 comments on commit 6195aba

Please sign in to comment.