array.push(Foo { ... })
should construct Foo
in-place
#35531
Labels
A-array
Area: `[T; N]`
A-MIR
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Right now when you push an immediate we construct a temporary copy on the stack and then move it into place on the heap. This is wasteful and results in a good deal of code bloat. Can we do better (with MIR perhaps)?
One possible sketch of a solution is to implement MIR inlining and then use some variant of #32966 that can prove that the construction of the argument to
push()
does not touch the vector, enabling us to forward the move from the stack to the destination ofptr::write()
.An alternative would be to implement rust-lang/rfcs#1426.
cc @eddyb @nikomatsakis
The text was updated successfully, but these errors were encountered: