Make a set of files directly instead of adding them to a vector in main.cpp
This commit is contained in:
parent
477337f96b
commit
700ab109d2
@ -16,7 +16,7 @@ int main(int argc, char* argv[]) {
|
||||
bool newLines = true;
|
||||
|
||||
if (argc > 0) {
|
||||
vector<string_view> files;
|
||||
set<string_view> files;
|
||||
for (signed int i = 0; i < argc; ++i)
|
||||
{
|
||||
const string_view currentArg (argv[i]);
|
||||
@ -28,7 +28,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
else if (currentArg == Argument("parallel")) parallel = true;
|
||||
else if (currentArg == Argument("newlinesoff")) newLines = false;
|
||||
else if (currentArg.ends_with(".ybcon")) files.push_back(currentArg);
|
||||
else if (currentArg.ends_with(".ybcon")) files.insert(currentArg);
|
||||
}
|
||||
const auto compile = [&target, &newLines](string_view name) -> string {
|
||||
string transpiledString = transpile(parseString(getFileContent(name.data())), target, newLines);
|
||||
@ -39,10 +39,9 @@ int main(int argc, char* argv[]) {
|
||||
return transpiledString;
|
||||
};
|
||||
if (!files.empty()) {
|
||||
const set<string_view> uniqueFiles(files.begin(), files.end());
|
||||
vector<future<pair<string, optional<Yerbacon::Exception>>>> Units;
|
||||
const launch& Policy = not parallel ? launch::deferred : launch::async;
|
||||
for (const string_view& fileName: uniqueFiles) {
|
||||
for (const string_view& fileName: files) {
|
||||
pair<string, optional<Yerbacon::Exception>> returnedPair;
|
||||
Units.push_back(async(Policy, [&returnedPair, &fileName, &compile]() {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user