From ffd8182804af45ab15228f1111ea77dc561b37c2 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 30 Jun 2020 13:54:43 -0500 Subject: [PATCH] Pre-allocate `seen` to improve inference in `unique(f, itr)` https://github.com/JuliaLang/julia/pull/36280 introduced the ability to pre-allocate the container used to track values of `f.(itr)` in `unique(f, itr)`. Particularly for containers with `Union` elements, this circumvents significant inference problems. Related: https://github.com/JuliaLang/julia/issues/36454 --- src/Registry.jl | 2 +- src/Types.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Registry.jl b/src/Registry.jl index c2d104b05d..be8f878e41 100644 --- a/src/Registry.jl +++ b/src/Registry.jl @@ -103,7 +103,7 @@ status(; kwargs...) = status(Context(); kwargs...) function status(ctx::Context; io::IO=stdout, as_api=false, kwargs...) # TODO split as_api into own function Context!(ctx; io=io, kwargs...) regs = Types.collect_registries() - regs = unique(r -> r.uuid, regs) # Maybe not? + regs = unique(r -> r.uuid, regs; seen=Set{Union{UUID,Nothing}}()) # Maybe not? as_api && return regs Types.printpkgstyle(ctx, Symbol("Registry Status"), "") if isempty(regs) diff --git a/src/Types.jl b/src/Types.jl index ee0939ca63..d9ac2d0d6a 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -1109,7 +1109,7 @@ function update_registries(ctx::Context, regs::Vector{RegistrySpec} = collect_re !force && UPDATED_REGISTRY_THIS_SESSION[] && return errors = Tuple{String, String}[] registry_urls = nothing - for reg in unique(r -> r.uuid, find_installed_registries(ctx, regs)) + for reg in unique(r -> r.uuid, find_installed_registries(ctx, regs); seen=Set{Union{UUID,Nothing}}()) let reg=reg regpath = pathrepr(reg.path) if isfile(joinpath(reg.path, ".tree_info.toml"))