From b45cfe5e437ca79bb3176618769628c58c0734d1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 Dec 2022 14:52:33 +0200 Subject: [PATCH] Use shortcut functions for find calls --- source/binarypackage.cpp | 4 ++-- source/component.cpp | 4 ++-- source/objectfile.cpp | 2 +- source/sourcearchivecomponent.cpp | 4 ++-- source/sourcepackage.cpp | 2 +- source/target.cpp | 4 ++-- source/tool.cpp | 9 ++------- source/vssolutionfile.cpp | 2 +- 8 files changed, 13 insertions(+), 18 deletions(-) diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 2c32d87..02b9be2 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "binarypackage.h" @@ -24,7 +24,7 @@ BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, c Flags exclusive_static_flags; for(const string &f: static_flags) - if(find(flags.begin(), flags.end(), f)==flags.end()) + if(!any_equals(flags, f)) exclusive_static_flags.push_back(f); process_flags(exclusive_static_flags, pkg->static_binfo); diff --git a/source/component.cpp b/source/component.cpp index 0e183b5..9636251 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -35,12 +35,12 @@ void Component::create_build_info() for(Package *r: all_reqs) { BuildInfo::UpdateLevel level = BuildInfo::CHAINED; - if(find(direct_reqs.begin(), direct_reqs.end(), r)!=direct_reqs.end()) + if(any_equals(direct_reqs, r)) level = BuildInfo::DEPENDENCY; final_build_info.update_from(r->get_exported_build_info(), level); for(Package *q: r->get_required_packages()) - if(find(all_reqs.begin(), all_reqs.end(), q)==all_reqs.end()) + if(!any_equals(all_reqs, q)) all_reqs.push_back(q); } diff --git a/source/objectfile.cpp b/source/objectfile.cpp index f78686e..256807c 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -103,7 +103,7 @@ void ObjectFile::find_dependencies(FileTarget *tgt) } for(Target *d: deps_to_add) - if(find(depends.begin(), depends.end(), d)==depends.end()) + if(!any_equals(depends, d)) { add_dependency(*d); if(d->get_real_target()->is_buildable()) diff --git a/source/sourcearchivecomponent.cpp b/source/sourcearchivecomponent.cpp index fdf82e5..027debc 100644 --- a/source/sourcearchivecomponent.cpp +++ b/source/sourcearchivecomponent.cpp @@ -1,4 +1,4 @@ -#include +#include #include "builder.h" #include "file.h" #include "sourcearchivecomponent.h" @@ -30,7 +30,7 @@ void SourceArchiveComponent::create_targets() const BuildGraph &build_graph = builder.get_build_graph(); for(const auto &kvp: build_graph.get_targets()) if(kvp.second->get_package()==&package && !kvp.second->is_buildable()) - if(find(files.begin(), files.end(), kvp.second)==files.end()) + if(!any_equals(files, kvp.second)) files.push_back(kvp.second); const Toolchain &toolchain = builder.get_toolchain(); diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index a89feb2..8c535e7 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -205,7 +205,7 @@ void SourcePackage::Loader::finish() { /* Make sure the source tarball is last in the list so targets from all other components wil be created first */ - ComponentList::iterator i = find(obj.components.begin(), obj.components.end(), obj.source_archive); + ComponentList::iterator i = find(obj.components, obj.source_archive); if(i!=obj.components.end()) obj.components.splice(obj.components.end(), obj.components, i); } diff --git a/source/target.cpp b/source/target.cpp index 49a7693..b741705 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -62,7 +62,7 @@ Target *Target::get_buildable_target() for(Target *d: depends) { // Avoid infinite recursion if a target repends on its own side effect - if(find(side_effects.begin(), side_effects.end(), d)!=side_effects.end()) + if(any_equals(side_effects, d)) continue; Target *tgt = d->get_buildable_target(); diff --git a/source/tool.cpp b/source/tool.cpp index 496132f..44255a1 100644 --- a/source/tool.cpp +++ b/source/tool.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "architecture.h" #include "builder.h" @@ -38,12 +38,7 @@ void Tool::set_command(const string &cmd, bool cross) bool Tool::accepts_suffix(const string &suffix, bool aux) const { - if(find(input_suffixes.begin(), input_suffixes.end(), suffix)!=input_suffixes.end()) - return true; - else if(aux) - return find(aux_suffixes.begin(), aux_suffixes.end(), suffix)!=aux_suffixes.end(); - else - return false; + return (any_equals(input_suffixes, suffix) || (aux && any_equals(aux_suffixes, suffix))); } Target *Tool::create_target(Target &source, const string &arg) diff --git a/source/vssolutionfile.cpp b/source/vssolutionfile.cpp index c667fc5..af7e01f 100644 --- a/source/vssolutionfile.cpp +++ b/source/vssolutionfile.cpp @@ -25,7 +25,7 @@ void VsSolutionFile::find_dependencies() add_dependency(*project); for(Package *r: spkg->get_required_packages()) - if(find(reqs, r)==reqs.end()) + if(!any_equals(reqs, r)) reqs.push_back(r); } } -- 2.45.2