Skip to content

Commit

Permalink
Precompile to reduce latency
Browse files Browse the repository at this point in the history
Motivated by JuliaLang/julia#43990 (comment),
but probably not a bad idea in its own right.
  • Loading branch information
timholy committed Jan 31, 2022
1 parent 72ad73e commit 7863789
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Preferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ list the given UUID as a direct dependency.
Most users should use the `@load_preference` convenience macro which auto-determines the
calling `Module`.
"""
function load_preference(uuid::UUID, key::String, default = nothing)
function load_preference(uuid::UUID, key::String, @nospecialize(default = nothing))
# Re-use definition in `base/loading.jl` so as to not repeat code.
d = Base.get_preferences(uuid)
if currently_compiling()
Expand Down Expand Up @@ -290,4 +290,9 @@ macro delete_preferences!(prefs...)
end
end

# Precompilation to reduce latency (https://github.com/JuliaLang/julia/pull/43990#issuecomment-1025692379)
get_uuid(Preferences)
currently_compiling()
precompile(load_preference, (Base.UUID, String, Nothing))

end # module Preferences

0 comments on commit 7863789

Please sign in to comment.