summaryrefslogtreecommitdiff
path: root/src/build.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-05-29 14:55:51 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-06-09 22:15:32 +0200
commitb74bd9e24e1205b7449404fd05172664b211d82c (patch)
treeaf69d4efbdddee347cd82c774880efa6820a0aa2 /src/build.cc
parent15eea63a6e7da37e7b4d643f189e6de150268ff8 (diff)
Make all task lists std::set instead of std::list to make sure to not contain duplicates.
Diffstat (limited to 'src/build.cc')
-rw-r--r--src/build.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/build.cc b/src/build.cc
index 8adbc54..b0b4d06 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -9,13 +9,14 @@
#include <chrono>
#include <set>
#include <thread>
+#include <list>
using namespace std::chrono_literals;
int build(const Settings& settings,
const std::string& name,
- const std::list<std::shared_ptr<Task>>& tasks,
- const std::list<std::shared_ptr<Task>>& all_tasks,
+ const std::set<std::shared_ptr<Task>>& tasks,
+ const std::set<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
if(settings.verbose > 1)
@@ -23,12 +24,12 @@ int build(const Settings& settings,
std::cout << "Building '" << name << "'\n";
}
- std::list<std::shared_ptr<Task>> dirtyTasks;
+ std::set<std::shared_ptr<Task>> dirtyTasks;
for(auto task : tasks)
{
if(task->dirty())
{
- dirtyTasks.push_back(task);
+ dirtyTasks.insert(task);
}
}
@@ -155,7 +156,7 @@ std::set<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task)
int build(const Settings& settings,
const std::string& name,
- const std::list<std::shared_ptr<Task>>& all_tasks,
+ const std::set<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
bool task_found{false};
@@ -172,10 +173,10 @@ int build(const Settings& settings,
task_found = true;
auto depSet = getDepTasks(task);
- std::list<std::shared_ptr<Task>> ts;
+ std::set<std::shared_ptr<Task>> ts;
for(const auto& task : depSet)
{
- ts.push_back(task);
+ ts.insert(task);
}
auto ret = build(settings, name, ts, all_tasks, dryrun);
@@ -200,11 +201,11 @@ int build(const Settings& settings,
int build(const Settings& settings,
const std::string& name,
const std::vector<Target>& targets,
- const std::list<std::shared_ptr<Task>>& all_tasks,
+ const std::set<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
bool task_found{false};
- std::list<std::shared_ptr<Task>> ts;
+ std::set<std::shared_ptr<Task>> ts;
for(const auto& target : targets)
{
@@ -218,7 +219,7 @@ int build(const Settings& settings,
auto depSet = getDepTasks(task);
for(const auto& task : depSet)
{
- ts.push_back(task);
+ ts.insert(task);
}
}
}