Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/Preferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ function load_preference(uuid::UUID, key::String, default = nothing)
if currently_compiling()
Base.record_compiletime_preference(uuid, key)
end
# Drop any nested `__clear__` keys:
function drop_clears(data::Dict)
delete!(data, "__clear__")
for (k, v) in data
if isa(v, Dict)
drop_clears(v)
end
end
return data
end
drop_clears(x) = x

return drop_clears(get(d, key, default))
end
function load_preference(m::Module, key::String, default = nothing)
Expand Down Expand Up @@ -290,4 +278,12 @@ 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(Tuple{typeof(drop_clears), Any})
if hasmethod(Base.BinaryPlatforms.Platform, (String, String, Dict{String}))
precompile(load_preference, (Base.UUID, String, Nothing))
end

end # module Preferences
11 changes: 11 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ function find_first_project_with_uuid(uuid::UUID)
end
return (nothing, nothing)
end

# Drop any nested `__clear__` keys:
function drop_clears(@nospecialize(data))
if isa(data, Dict{String,Any})
delete!(data, "__clear__")
for (_, v) in data
drop_clears(v)
end
end
return data
end