aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-04 09:46:14 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-04 20:33:50 -0800
commite74f4919aa0fd86cc835f21d091585737d80fe19 (patch)
treef6b5baee4de7b673c4077c14dbc4100b3a5208e2 /paludis
parent0b8d41cdb90b0fd0a7c39166c471a888622ab455 (diff)
downloadpaludis-e74f4919aa0fd86cc835f21d091585737d80fe19.tar.gz
paludis-e74f4919aa0fd86cc835f21d091585737d80fe19.tar.xz
use range based for loops more pervasively (NFC)
Diffstat (limited to 'paludis')
-rw-r--r--paludis/args/args_option.cc6
-rw-r--r--paludis/args/args_option.hh3
-rw-r--r--paludis/filter.cc118
-rw-r--r--paludis/package_dep_spec_collection.cc5
-rw-r--r--paludis/resolver/allowed_to_remove_helper.cc5
-rw-r--r--paludis/resolver/decider.cc15
-rw-r--r--paludis/resolver/get_resolvents_for_helper.cc11
7 files changed, 70 insertions, 93 deletions
diff --git a/paludis/args/args_option.cc b/paludis/args/args_option.cc
index 4ae2e07f9..92565231b 100644
--- a/paludis/args/args_option.cc
+++ b/paludis/args/args_option.cc
@@ -222,6 +222,12 @@ StringSetArg::end_args() const
return ConstIterator(_imp->args.end());
}
+IteratorRange<StringSetArg::ConstIterator>
+StringSetArg::args() const
+{
+ return {_imp->args};
+}
+
void
StringSetArg::add_argument(const std::string & arg)
{
diff --git a/paludis/args/args_option.hh b/paludis/args/args_option.hh
index 96858594c..8c0301302 100644
--- a/paludis/args/args_option.hh
+++ b/paludis/args/args_option.hh
@@ -21,6 +21,7 @@
#ifndef PALUDIS_GUARD_ARGS_ARGS_OPTION_HH
#define PALUDIS_GUARD_ARGS_ARGS_OPTION_HH 1
+#include <paludis/util/iterator_range.hh>
#include <paludis/util/pimp.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/type_list.hh>
@@ -350,8 +351,8 @@ namespace paludis
typedef WrappedForwardIterator<ConstIteratorTag, const std::string> ConstIterator;
ConstIterator begin_args() const;
-
ConstIterator end_args() const;
+ IteratorRange<ConstIterator> args() const;
///\}
diff --git a/paludis/filter.cc b/paludis/filter.cc
index 0d6cf1697..ea569ecf9 100644
--- a/paludis/filter.cc
+++ b/paludis/filter.cc
@@ -133,34 +133,26 @@ namespace
struct SupportsActionFilterHandler :
AllFilterHandlerBase
{
- std::shared_ptr<const RepositoryNameSet> repositories(
- const Environment * const env,
- const std::shared_ptr<const RepositoryNameSet> & repos) const override
+ std::shared_ptr<const RepositoryNameSet>
+ repositories(const Environment * const env, const std::shared_ptr<const RepositoryNameSet> & repos) const override
{
std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
- r != r_end ; ++r)
- {
- if (env->fetch_repository(*r)->some_ids_might_support_action(SupportsActionTest<A_>()))
- result->insert(*r);
- }
+ for (const auto & repository : *repos)
+ if (env->fetch_repository(repository)->some_ids_might_support_action(SupportsActionTest<A_>()))
+ result->insert(repository);
return result;
}
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- {
- if ((*i)->supports_action(SupportsActionTest<A_>()))
- result->insert(*i);
- }
+ for (const auto & id : *set)
+ if (id->supports_action(SupportsActionTest<A_>()))
+ result->insert(id);
return result;
}
@@ -179,32 +171,26 @@ namespace
return { rcme_masked };
}
- std::shared_ptr<const RepositoryNameSet> repositories(
- const Environment * const env,
- const std::shared_ptr<const RepositoryNameSet> & repos) const override
+ std::shared_ptr<const RepositoryNameSet>
+ repositories(const Environment * const env, const std::shared_ptr<const RepositoryNameSet> & repos) const override
{
std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
- r != r_end ; ++r)
- {
- if (env->fetch_repository(*r)->some_ids_might_not_be_masked())
- result->insert(*r);
- }
+ for (const auto & repository : *repos)
+ if (env->fetch_repository(repository)->some_ids_might_not_be_masked())
+ result->insert(repository);
return result;
}
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- if (! (*i)->masked())
- result->insert(*i);
+ for (const auto & id : *set)
+ if (! id->masked())
+ result->insert(id);
return result;
}
@@ -232,32 +218,28 @@ namespace
return { rcme_not_installed };
}
- std::shared_ptr<const RepositoryNameSet> repositories(
- const Environment * const env,
- const std::shared_ptr<const RepositoryNameSet> & repos) const override
+ std::shared_ptr<const RepositoryNameSet>
+ repositories(const Environment * const env, const std::shared_ptr<const RepositoryNameSet> & repos) const override
{
std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
- r != r_end ; ++r)
+ for (const auto & repository : *repos)
{
- const std::shared_ptr<const Repository> repo(env->fetch_repository(*r));
+ const std::shared_ptr<const Repository> repo(env->fetch_repository(repository));
if (repo->installed_root_key() && (equal == (root == repo->installed_root_key()->parse_value())))
- result->insert(*r);
+ result->insert(repository);
}
return result;
}
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- result->insert(*i);
+ for (const auto & id : *set)
+ result->insert(id);
return result;
}
@@ -337,24 +319,24 @@ namespace
return { };
}
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
+ for (const auto & id : *set)
+ {
if (as_id->slot_key())
{
- if ((*i)->slot_key() && (*i)->slot_key()->parse_value().parallel_value() == as_id->slot_key()->parse_value().parallel_value())
- result->insert(*i);
+ if (id->slot_key() && id->slot_key()->parse_value().parallel_value() == as_id->slot_key()->parse_value().parallel_value())
+ result->insert(id);
}
else
{
- if (! (*i)->slot_key())
- result->insert(*i);
+ if (! id->slot_key())
+ result->insert(id);
}
+ }
return result;
}
@@ -380,16 +362,14 @@ namespace
return { };
}
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- if ((*i)->slot_key() && (*i)->slot_key()->parse_value().parallel_value() == slot)
- result->insert(*i);
+ for (const auto & id : *set)
+ if (id->slot_key() && id->slot_key()->parse_value().parallel_value() == slot)
+ result->insert(id);
return result;
}
@@ -403,16 +383,14 @@ namespace
struct NoSlotHandler :
AllFilterHandlerBase
{
- std::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::shared_ptr<const PackageIDSet> & id) const override
+ std::shared_ptr<const PackageIDSet>
+ ids(const Environment * const, const std::shared_ptr<const PackageIDSet> & set) const override
{
std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>());
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- if (! (*i)->slot_key())
- result->insert(*i);
+ for (const auto & id : *set)
+ if (! id->slot_key())
+ result->insert(id);
return result;
}
diff --git a/paludis/package_dep_spec_collection.cc b/paludis/package_dep_spec_collection.cc
index 017f58740..1140b9722 100644
--- a/paludis/package_dep_spec_collection.cc
+++ b/paludis/package_dep_spec_collection.cc
@@ -70,9 +70,8 @@ PackageDepSpecCollection::match_any(
if (match_package(*env, named.first->second, id, _imp->from_id, opts))
return true;
- for (auto u(_imp->unnamed.begin()), u_end(_imp->unnamed.end()) ;
- u != u_end ; ++u)
- if (match_package(*env, *u, id, _imp->from_id, opts))
+ for (const auto & unnamed : _imp->unnamed)
+ if (match_package(*env, unnamed, id, _imp->from_id, opts))
return true;
return false;
diff --git a/paludis/resolver/allowed_to_remove_helper.cc b/paludis/resolver/allowed_to_remove_helper.cc
index c628dfea9..fdc2e7588 100644
--- a/paludis/resolver/allowed_to_remove_helper.cc
+++ b/paludis/resolver/allowed_to_remove_helper.cc
@@ -78,9 +78,8 @@ AllowedToRemoveHelper::operator() (
}
);
- for (auto c(resolution->constraints()->begin()), c_end(resolution->constraints()->end()) ;
- c != c_end ; ++c)
- if ((*c)->reason()->accept_returning<bool>(v))
+ for (const auto & constraint : *resolution->constraints())
+ if (constraint->reason()->accept_returning<bool>(v))
return true;
return _imp->allowed_to_remove_specs.match_any(_imp->env, id, { });
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 4a20df9b2..da0dfddcb 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -999,20 +999,15 @@ Decider::_copy_other_destination_constraints(const std::shared_ptr<Resolution> &
Resolvent copy_from_resolvent(resolution->resolvent());
copy_from_resolvent.destination_type() = *t;
- const std::shared_ptr<Resolution> copy_from_resolution(
- _resolution_for_resolvent(copy_from_resolvent, indeterminate));
+ const std::shared_ptr<Resolution> copy_from_resolution(_resolution_for_resolvent(copy_from_resolvent, indeterminate));
if (! copy_from_resolution)
continue;
- for (Constraints::ConstIterator c(copy_from_resolution->constraints()->begin()),
- c_end(copy_from_resolution->constraints()->end()) ;
- c != c_end ; ++c)
+ for (const auto & copy : *copy_from_resolution->constraints())
{
- const std::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_other_destination(
- resolution, copy_from_resolution, *c));
- for (ConstraintSequence::ConstIterator d(constraints->begin()), d_end(constraints->end()) ;
- d != d_end ; ++d)
- _apply_resolution_constraint(resolution, *d);
+ const std::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_other_destination(resolution, copy_from_resolution, copy));
+ for (const auto & constraint : *constraints)
+ _apply_resolution_constraint(resolution, constraint);
}
}
}
diff --git a/paludis/resolver/get_resolvents_for_helper.cc b/paludis/resolver/get_resolvents_for_helper.cc
index 226a1f149..d6df5a302 100644
--- a/paludis/resolver/get_resolvents_for_helper.cc
+++ b/paludis/resolver/get_resolvents_for_helper.cc
@@ -359,19 +359,18 @@ GetResolventsForHelper::operator() (
{
result.second = true;
- for (PackageIDSequence::ConstIterator i(result_ids->begin()), i_end(result_ids->end()) ;
- i != i_end ; ++i)
+ for (const auto & id : *result_ids)
{
- DestinationTypes destination_types(get_destination_types_for_fn(_imp->env, spec,
- _imp->target_destination_type, _imp->want_target_dependencies, _imp->want_target_runtime_dependencies,
- _imp->want_dependencies_on_slash, _imp->want_runtime_dependencies_on_slash, *i, reason));
+ DestinationTypes destination_types(get_destination_types_for_fn(_imp->env, spec, _imp->target_destination_type, _imp->want_target_dependencies,
+ _imp->want_target_runtime_dependencies, _imp->want_dependencies_on_slash,
+ _imp->want_runtime_dependencies_on_slash, id, reason));
if (destination_types.any())
{
result.second = false;
for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
if (destination_types[*t])
- result.first->push_back(Resolvent(*i, *t));
+ result.first->push_back(Resolvent(id, *t));
}
}
}