From 20eff1d7b51bb928c3f66145767cdadb3fae5e8b Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Tue, 5 Oct 2021 09:28:43 +0200 Subject: [PATCH] Set the initial size of Units to the number of files instead of allocating memory and using a back_inserter --- src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index af0e85c..78e0f10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,10 +40,9 @@ int main(int argc, char* argv[]) { return transpiledString; }; if (!files.empty()) { - vector>>> Units; + vector>>> Units(files.size()); const launch& Policy = not parallel ? launch::deferred : launch::async; - Units.reserve(files.size()); - transform(files.begin(), files.end(), back_inserter(Units), [&Policy, &compile](const string_view& fileName){ + transform(files.begin(), files.end(), Units.begin(), [&Policy, &compile](const string_view& fileName){ return async(Policy, [&fileName, &compile]() { pair> resultingPair; try {