Skip to content

Commit

Permalink
Add more precompile and fix an inference problem (#89)
Browse files Browse the repository at this point in the history
Together with changes in Julia, this shaves about 100ms off the time to load
a simple Requires-dependent package.
  • Loading branch information
timholy authored and KristofferC committed Oct 28, 2021
1 parent 8067024 commit 1d46dd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Requires.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if isprecompiling()
@assert precompile(err, (Any, Module, String))
@assert precompile(parsepkg, (Expr,))
@assert precompile(listenpkg, (Any, Base.PkgId))
@assert precompile(callbacks, (Base.PkgId,))
end

end # module
2 changes: 1 addition & 1 deletion src/require.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loaded(pkg) = haskey(Base.loaded_modules, pkg)
const notified_pkgs = [Base.PkgId(UUID(0x295af30fe4ad537b898300126c2a3abe), "Revise")]

const _callbacks = Dict{PkgId, Vector{Function}}()
callbacks(pkg) = get!(()->[], _callbacks, pkg)
callbacks(pkg) = get!(Vector{Function}, _callbacks, pkg)

listenpkg(@nospecialize(f), pkg) =
loaded(pkg) ? f() : push!(callbacks(pkg), f)
Expand Down

0 comments on commit 1d46dd5

Please sign in to comment.