Skip to content

Commit

Permalink
slightly improve inference in precompilation code (#56084)
Browse files Browse the repository at this point in the history
Avoids the

```
11: signature Tuple{typeof(convert), Type{String}, Any} triggered MethodInstance for Base.Precompilation.ExplicitEnv(::String) (84 children)
```

shown in
#56080 (comment)

Co-authored-by: KristofferC <[email protected]>
  • Loading branch information
KristofferC and KristofferC authored Oct 10, 2024
1 parent a233425 commit dc609a7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Collect all direct dependencies of the project
for key in ["deps", "weakdeps", "extras"]
for (name, _uuid) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
for (name, _uuid::String) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
v = key == "deps" ? project_deps :
key == "weakdeps" ? project_weakdeps :
key == "extras" ? project_extras :
Expand Down Expand Up @@ -107,9 +107,8 @@ function ExplicitEnv(envpath::String=Base.active_project())
sizehint!(name_to_uuid, length(manifest_d))
sizehint!(lookup_strategy, length(manifest_d))

for (name, pkg_infos) in get_deps(manifest_d)
pkg_infos = pkg_infos::Vector{Any}
for pkg_info in pkg_infos
for (name, pkg_infos::Vector{Any}) in get_deps(manifest_d)
for pkg_info::Dict{String, Any} in pkg_infos
m_uuid = UUID(pkg_info["uuid"]::String)

# If we have multiple packages with the same name we will overwrite things here
Expand Down Expand Up @@ -141,8 +140,7 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Extensions
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
for (ext, triggers) in deps_pkg
triggers = triggers::Union{String, Vector{String}}
for (ext, triggers::Union{String, Vector{String}}) in deps_pkg
if triggers isa String
triggers = [triggers]
end
Expand Down Expand Up @@ -176,7 +174,7 @@ function ExplicitEnv(envpath::String=Base.active_project())
if proj_name !== nothing && proj_uuid !== nothing
deps_expanded[proj_uuid] = filter!(!=(proj_uuid), collect(values(project_deps)))
extensions_expanded[proj_uuid] = project_extensions
path = get(project_d, "path", nothing)
path = get(project_d, "path", nothing)::Union{String, Nothing}
entry_point = path !== nothing ? path : dirname(envpath)
lookup_strategy[proj_uuid] = entry_point
end
Expand Down

0 comments on commit dc609a7

Please sign in to comment.