Skip to content
Merged
Changes from all commits
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
9 changes: 8 additions & 1 deletion base/toml_parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,20 @@ end
#########

function push!!(v::Vector, el)
# Since these types are typically non-inferrable, they are a big invalidation risk,
Copy link
Member

Choose a reason for hiding this comment

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

Fantastic comment! :)

# and since it's used by the package-loading infrastructure the cost of invalidation
# is high. Therefore, this is written to reduce the "exposed surface area": e.g., rather
# than writing `T[el]` we write it as `push!(Vector{T}(undef, 1), el)` so that there
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny nit, but push!(Vector{T}(undef, 1), el) should be push!(Vector{T}(undef, 0), el) or the version in the code, right?

# is no ambiguity about what types of objects will be created.
T = eltype(v)
t = typeof(el)
if el isa T || t === T
push!(v, el::T)
return v
elseif T === Union{}
return t[el]
out = Vector{t}(undef, 1)
out[1] = el
return out
else
if typeof(T) === Union
newT = Any
Expand Down