From b74bd9e24e1205b7449404fd05172664b211d82c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 29 May 2022 14:55:51 +0200 Subject: Make all task lists std::set instead of std::list to make sure to not contain duplicates. --- src/build.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/build.cc') 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 #include #include +#include using namespace std::chrono_literals; int build(const Settings& settings, const std::string& name, - const std::list>& tasks, - const std::list>& all_tasks, + const std::set>& tasks, + const std::set>& all_tasks, bool dryrun) { if(settings.verbose > 1) @@ -23,12 +24,12 @@ int build(const Settings& settings, std::cout << "Building '" << name << "'\n"; } - std::list> dirtyTasks; + std::set> dirtyTasks; for(auto task : tasks) { if(task->dirty()) { - dirtyTasks.push_back(task); + dirtyTasks.insert(task); } } @@ -155,7 +156,7 @@ std::set> getDepTasks(std::shared_ptr task) int build(const Settings& settings, const std::string& name, - const std::list>& all_tasks, + const std::set>& 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> ts; + std::set> 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& targets, - const std::list>& all_tasks, + const std::set>& all_tasks, bool dryrun) { bool task_found{false}; - std::list> ts; + std::set> 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); } } } -- cgit v1.2.3