diff --git a/src/API.jl b/src/API.jl index ff92efaa34..e1b8a2bc5d 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1248,19 +1248,21 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool # if a list of packages is given, restrict to dependencies of given packages if !isempty(pkgs) pkgs_names = [p.name for p in pkgs] - function collect_all_deps(depsmap, dep, alldeps=Base.PkgId[]) - append!(alldeps, depsmap[dep]) + function collect_all_deps(depsmap, dep, alldeps=Set{Base.PkgId}()) for _dep in depsmap[dep] - collect_all_deps(depsmap, _dep, alldeps) + if !(_dep in alldeps) + push!(alldeps, _dep) + collect_all_deps(depsmap, _dep, alldeps) + end end return alldeps end - keep = Base.PkgId[] + keep = Set{Base.PkgId}() for dep in depsmap dep_pkgid = first(dep) if dep_pkgid.name in pkgs_names push!(keep, dep_pkgid) - append!(keep, collect_all_deps(depsmap, dep_pkgid)) + collect_all_deps(depsmap, dep_pkgid, keep) end end for ext in keys(exts)