Set the initial size of Units to the number of files instead of allocating memory and using a back_inserter

This commit is contained in:
Username404-59 2021-10-05 09:28:43 +02:00
parent e04fc67aae
commit 20eff1d7b5
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 2 additions and 3 deletions

View File

@ -40,10 +40,9 @@ int main(int argc, char* argv[]) {
return transpiledString;
};
if (!files.empty()) {
vector<future<pair<string, optional<Yerbacon::Exception>>>> Units;
vector<future<pair<string, optional<Yerbacon::Exception>>>> 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<string, optional<Yerbacon::Exception>> resultingPair;
try {