From 89ada6c51fbdf59dcab8a1e479f60196d29bd4d3 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 2 Jan 2023 16:47:08 -0500 Subject: [PATCH] llvm-reduce: Avoid push_back for constant array --- llvm/tools/llvm-reduce/TestRunner.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/tools/llvm-reduce/TestRunner.cpp b/llvm/tools/llvm-reduce/TestRunner.cpp index 058664d..3d486f8 100644 --- a/llvm/tools/llvm-reduce/TestRunner.cpp +++ b/llvm/tools/llvm-reduce/TestRunner.cpp @@ -31,6 +31,10 @@ TestRunner::TestRunner(StringRef TestName, assert(this->Program && "Initialized with null program?"); } +static constexpr std::array, 3> DefaultRedirects = { + StringRef()}; +static constexpr std::array, 3> NullRedirects; + /// Runs the interestingness test, passes file to be tested as first argument /// and other specified test arguments after that. int TestRunner::run(StringRef Filename) const { @@ -43,15 +47,11 @@ int TestRunner::run(StringRef Filename) const { ProgramArgs.push_back(Filename); std::string ErrMsg; - SmallVector, 3> Redirects; - std::optional Empty = StringRef(); - if (!Verbose) { - for (int i = 0; i < 3; ++i) - Redirects.push_back(Empty); - } - int Result = sys::ExecuteAndWait( - TestName, ProgramArgs, /*Env=*/std::nullopt, Redirects, - /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg); + + int Result = + sys::ExecuteAndWait(TestName, ProgramArgs, /*Env=*/std::nullopt, + Verbose ? DefaultRedirects : NullRedirects, + /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg); if (Result < 0) { Error E = make_error("Error running interesting-ness test: " + -- 2.7.4