]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: reconstruct_vec: Allocate size when creating the vector
authorArthur Cohen <arthur.cohen@embecosm.com>
Mon, 26 May 2025 09:31:40 +0000 (11:31 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:52 +0000 (16:36 +0200)
gcc/rust/ChangeLog:

* ast/rust-ast.h (reconstruct_vec): Pre-allocate size of vector.

gcc/rust/ast/rust-ast.h

index ecbc291813009696fdb2ed93ed2826304697d38b..0d853e744c76b5e3d066bdfcaa6f75d45617fbc3 100644 (file)
@@ -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 ()));