gdb: simplify vector construction in eval_op_rust_array

Message ID 20230830152126.976163-1-simon.marchi@efficios.com
State New
Headers
Series gdb: simplify vector construction in eval_op_rust_array |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch is already merged

Commit Message

Simon Marchi Aug. 30, 2023, 3:21 p.m. UTC
  Replace the manual fill of the vector with the appropriate std::vector
constructor that makes N copies of the provided value.

Change-Id: I579570748c48f53d35024105269d83c716294746
---
 gdb/rust-lang.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)


base-commit: 59487af3c8490bc5961d330bc0ef4d5f05ecdc59
  

Comments

Tom Tromey Aug. 30, 2023, 5:09 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> Replace the manual fill of the vector with the appropriate std::vector
Simon> constructor that makes N copies of the provided value.

Thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Simon Marchi Aug. 30, 2023, 6:32 p.m. UTC | #2
On 8/30/23 13:09, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> Replace the manual fill of the vector with the appropriate std::vector
> Simon> constructor that makes N copies of the provided value.
> 
> Thanks.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks, pushed.

Simon
  

Patch

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 0e2ca090ba8c..5f97d24f2572 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1338,14 +1338,7 @@  eval_op_rust_array (struct type *expect_type, struct expression *exp,
     error (_("Array with negative number of elements"));
 
   if (noside == EVAL_NORMAL)
-    {
-      int i;
-      std::vector<struct value *> eltvec (copies);
-
-      for (i = 0; i < copies; ++i)
-	eltvec[i] = elt;
-      return value_array (0, eltvec);
-    }
+    return value_array (0, std::vector<value *> (copies, elt));
   else
     {
       struct type *arraytype