From 7c651c5fe6de738b0ce9b5b89568fde84eade807 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 30 Aug 2023 11:21:20 -0400 Subject: [PATCH] gdb: simplify vector construction in eval_op_rust_array Replace the manual fill of the vector with the appropriate std::vector constructor that makes N copies of the provided value. Change-Id: I579570748c48f53d35024105269d83c716294746 Approved-By: Tom Tromey --- gdb/rust-lang.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 0e2ca090ba8..5f97d24f257 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 eltvec (copies); - - for (i = 0; i < copies; ++i) - eltvec[i] = elt; - return value_array (0, eltvec); - } + return value_array (0, std::vector (copies, elt)); else { struct type *arraytype -- 2.30.2