From 78637893bbddb1a19491c9da820cfbe03aa0b139 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 31 Jan 2022 15:14:40 -0600 Subject: [PATCH] Precompile to reduce latency Motivated by https://github.com/JuliaLang/julia/pull/43990#issuecomment-1025692379, but probably not a bad idea in its own right. --- src/Preferences.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Preferences.jl b/src/Preferences.jl index 5ff7231..529cf2a 100644 --- a/src/Preferences.jl +++ b/src/Preferences.jl @@ -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() @@ -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