Skip to content

Commit

Permalink
Pre-allocate seen to improve inference in unique(f, itr)
Browse files Browse the repository at this point in the history
JuliaLang/julia#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: JuliaLang/julia#36454
  • Loading branch information
timholy committed Jun 30, 2020
1 parent 160efbe commit 0ebffb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Registry
import ..Pkg, ..Types, ..API
using ..Pkg: depots1
using ..Types: RegistrySpec, Context, Context!

using UUIDs

"""
Pkg.Registry.add(url::String)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 0ebffb9

Please sign in to comment.