From 0d560db400502a78b604af3ffb1ffed4337e611f Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Fri, 28 Aug 2020 10:44:19 -0500 Subject: [PATCH] Add more precompile and fix an inference problem (#89) Together with changes in Julia, this shaves about 100ms off the time to load a simple Requires-dependent package. --- src/Requires.jl | 1 + src/require.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Requires.jl b/src/Requires.jl index 3af59c0..8a27f33 100644 --- a/src/Requires.jl +++ b/src/Requires.jl @@ -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 diff --git a/src/require.jl b/src/require.jl index 0525a71..f3917b1 100644 --- a/src/require.jl +++ b/src/require.jl @@ -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)