Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve inferrability of prune_graph! #3202

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/Resolve/graphtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,13 @@ function prune_graph!(graph::Graph)
return pvers0[vmsk0[1:(end-1)]]
end
new_pvers = [compute_pvers(new_p0) for new_p0 = 1:new_np]
new_vdict = [Dict(vn => v0 for (v0,vn) in enumerate(new_pvers[new_p0])) for new_p0 = 1:new_np]
new_vdict = Vector{Dict{VersionNumber, Int}}(undef, length(new_pvers))
for new_p0 in eachindex(new_vdict)
new_vdict[new_p0] = Dict(vn => v0 for (v0,vn) in enumerate(new_pvers[new_p0]))
end
Comment on lines +1444 to +1447
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't

new_vdict = Dict{VersionNumber, Int}[Dict(vn => v0 for (v0,vn) in enumerate(new_pvers[new_p0])) for new_p0 = 1:new_np]

also work?

# The code above is essentially equivalent to
# new_vdict = [Dict(vn => v0 for (v0,vn) in enumerate(new_pvers[new_p0])) for new_p0 = 1:new_np]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole chunk can used be written as

# explicitly writing out the loop since the generator equivalent caused type inference failure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will be AFK in the next few days. Could you please make the changes you suggested? Otherwise, I will revisit this some time in October.

# but leads to improved type stability and reduced invalidations.

# The new constraints are all going to be `true`, except possibly
# for the "uninstalled" state, which we copy over from the old
Expand Down