https://gcc.gnu.org/g:1c4521b39702ffae7d737479926cd5e1ab34c564
commit r16-2909-g1c4521b39702ffae7d737479926cd5e1ab34c564 Author: Arthur Cohen <arthur.co...@embecosm.com> Date: Mon May 26 11:31:40 2025 +0200 gccrs: reconstruct_vec: Allocate size when creating the vector gcc/rust/ChangeLog: * ast/rust-ast.h (reconstruct_vec): Pre-allocate size of vector. Diff: --- gcc/rust/ast/rust-ast.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index ecbc29181300..0d853e744c76 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -107,6 +107,7 @@ std::vector<std::unique_ptr<T>> reconstruct_vec (const std::vector<std::unique_ptr<T>> &to_reconstruct) { std::vector<std::unique_ptr<T>> reconstructed; + reconstructed.reserve (to_reconstruct.size ()); for (const auto &elt : to_reconstruct) reconstructed.emplace_back (std::unique_ptr<T> (elt->reconstruct_impl ()));