aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-08 20:11:20 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-08 21:10:52 -0800
commit0b2ccb305258c86d78708f01eee7095effabe61d (patch)
tree3f6678b63f2d42c9ee26665ef1b2a441178f5be5 /paludis
parent1ae9a665aab39d1f4f51ea05979c477fc97b9a5a (diff)
downloadpaludis-0b2ccb305258c86d78708f01eee7095effabe61d.tar.gz
paludis-0b2ccb305258c86d78708f01eee7095effabe61d.tar.xz
resolver: whitespace, style cleanups
Avoid else return, use range based loop. Rename resolvent from `q` to `r`.
Diffstat (limited to 'paludis')
-rw-r--r--paludis/resolver/allowed_to_remove_helper.cc33
-rw-r--r--paludis/resolver/allowed_to_remove_helper.hh5
-rw-r--r--paludis/resolver/decider.cc6
-rw-r--r--paludis/resolver/destination_utils.cc7
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.cc13
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.hh7
-rw-r--r--paludis/resolver/get_initial_constraints_for_helper.cc39
-rw-r--r--paludis/resolver/get_initial_constraints_for_helper.hh3
-rw-r--r--paludis/resolver/interest_in_spec_helper.cc46
-rw-r--r--paludis/resolver/make_destination_filtered_generator_helper.cc8
-rw-r--r--paludis/resolver/make_destination_filtered_generator_helper.hh5
-rw-r--r--paludis/resolver/remove_if_dependent_helper.cc7
-rw-r--r--paludis/resolver/remove_if_dependent_helper.hh3
13 files changed, 67 insertions, 115 deletions
diff --git a/paludis/resolver/allowed_to_remove_helper.cc b/paludis/resolver/allowed_to_remove_helper.cc
index fdc2e75..8db14c4 100644
--- a/paludis/resolver/allowed_to_remove_helper.cc
+++ b/paludis/resolver/allowed_to_remove_helper.cc
@@ -37,9 +37,7 @@ namespace paludis
const Environment * const env;
PackageDepSpecCollection allowed_to_remove_specs;
- Imp(const Environment * const e) :
- env(e),
- allowed_to_remove_specs(nullptr)
+ Imp(const Environment * const e) : env(e), allowed_to_remove_specs(nullptr)
{
}
};
@@ -59,30 +57,23 @@ AllowedToRemoveHelper::add_allowed_to_remove_spec(const PackageDepSpec & spec)
}
bool
-AllowedToRemoveHelper::operator() (
- const std::shared_ptr<const Resolution> & resolution,
- const std::shared_ptr<const PackageID> & id) const
+AllowedToRemoveHelper::operator()(const std::shared_ptr<const Resolution> & resolution,
+ const std::shared_ptr<const PackageID> & id) const
{
- auto v = make_visitor(
- [&] (const DependentReason &) { return true; },
- [&] (const TargetReason &) { return true; },
- [&] (const DependencyReason &) { return false; },
- [&] (const WasUsedByReason &) { return true; },
- [&] (const ViaBinaryReason &) { return false; },
- [&] (const PresetReason &) { return false; },
- [&] (const SetReason & r, const Revisit<bool, Reason> & revisit) {
- return revisit(*r.reason_for_set());
- },
- [&] (const LikeOtherDestinationTypeReason & r, const Revisit<bool, Reason> & revisit) {
- return revisit(*r.reason_for_other());
- }
- );
+ auto v = make_visitor([&](const DependentReason &) { return true; },
+ [&](const TargetReason &) { return true; },
+ [&](const DependencyReason &) { return false; },
+ [&](const WasUsedByReason &) { return true; },
+ [&](const ViaBinaryReason &) { return false; },
+ [&](const PresetReason &) { return false; },
+ [&](const SetReason & r, const Revisit<bool, Reason> & revisit) { return revisit(*r.reason_for_set()); },
+ [&](const LikeOtherDestinationTypeReason & r, const Revisit<bool, Reason> & revisit) { return revisit(*r.reason_for_other()); });
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, { });
+ return _imp->allowed_to_remove_specs.match_any(_imp->env, id, {});
}
namespace paludis
diff --git a/paludis/resolver/allowed_to_remove_helper.hh b/paludis/resolver/allowed_to_remove_helper.hh
index 27ca4a4..abe3f71 100644
--- a/paludis/resolver/allowed_to_remove_helper.hh
+++ b/paludis/resolver/allowed_to_remove_helper.hh
@@ -44,9 +44,8 @@ namespace paludis
void add_allowed_to_remove_spec(const PackageDepSpec &);
- bool operator() (
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> &) const;
+ bool operator()(const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> &) const;
};
}
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index da0dfdd..286b3d4 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1681,10 +1681,8 @@ Decider::_installed_ids(const std::shared_ptr<const Resolution> & resolution) co
{
Context context("When finding installed IDs for '" + stringify(resolution->resolvent()) + "':");
- return (*_imp->env)[selection::AllVersionsSorted(
- _imp->fns.make_destination_filtered_generator_fn()(generator::Package(resolution->resolvent().package()), resolution) |
- make_slot_filter(resolution->resolvent())
- )];
+ return (*_imp->env)[selection::AllVersionsSorted(_imp->fns.make_destination_filtered_generator_fn()(generator::Package(resolution->resolvent().package()), resolution) |
+ make_slot_filter(resolution->resolvent()))];
}
const std::shared_ptr<const PackageIDSequence>
diff --git a/paludis/resolver/destination_utils.cc b/paludis/resolver/destination_utils.cc
index 0a02e60..6f741ab 100644
--- a/paludis/resolver/destination_utils.cc
+++ b/paludis/resolver/destination_utils.cc
@@ -97,10 +97,9 @@ namespace
}
FilteredGenerator
-paludis::resolver::destination_filtered_generator(
- const Environment * const env,
- const DestinationType t,
- const Generator & g)
+paludis::resolver::destination_filtered_generator(const Environment * const env,
+ const DestinationType t,
+ const Generator & g)
{
switch (t)
{
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.cc b/paludis/resolver/get_constraints_for_dependent_helper.cc
index fc6cff3..4e45398 100644
--- a/paludis/resolver/get_constraints_for_dependent_helper.cc
+++ b/paludis/resolver/get_constraints_for_dependent_helper.cc
@@ -47,9 +47,7 @@ namespace paludis
const Environment * const env;
PackageDepSpecCollection less_restrictive_remove_blockers_specs;
- Imp(const Environment * const e) :
- env(e),
- less_restrictive_remove_blockers_specs(nullptr)
+ Imp(const Environment * const e) : env(e), less_restrictive_remove_blockers_specs(nullptr)
{
}
};
@@ -69,16 +67,17 @@ GetConstraintsForDependentHelper::add_less_restrictive_remove_blockers_spec(cons
}
const std::shared_ptr<ConstraintSequence>
-GetConstraintsForDependentHelper::operator() (
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const DependentPackageIDSequence> & dependent_upon_ids) const
+GetConstraintsForDependentHelper::operator()(const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const DependentPackageIDSequence> & dependent_upon_ids) const
{
auto result(std::make_shared<ConstraintSequence>());
std::shared_ptr<PackageDepSpec> spec;
if (_imp->less_restrictive_remove_blockers_specs.match_any(_imp->env, id, { }))
+ {
spec = make_shared_copy(id->uniquely_identifying_spec());
+ }
else
{
PartiallyMadePackageDepSpec partial_spec({ });
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.hh b/paludis/resolver/get_constraints_for_dependent_helper.hh
index 66d6636..b5f30ca 100644
--- a/paludis/resolver/get_constraints_for_dependent_helper.hh
+++ b/paludis/resolver/get_constraints_for_dependent_helper.hh
@@ -50,10 +50,9 @@ namespace paludis
void add_less_restrictive_remove_blockers_spec(const PackageDepSpec &);
- const std::shared_ptr<ConstraintSequence> operator() (
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const PackageID> &,
- const std::shared_ptr<const DependentPackageIDSequence> &) const;
+ const std::shared_ptr<ConstraintSequence> operator()(const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const DependentPackageIDSequence> &) const;
};
}
diff --git a/paludis/resolver/get_initial_constraints_for_helper.cc b/paludis/resolver/get_initial_constraints_for_helper.cc
index 8a7de95..a132700 100644
--- a/paludis/resolver/get_initial_constraints_for_helper.cc
+++ b/paludis/resolver/get_initial_constraints_for_helper.cc
@@ -138,8 +138,7 @@ GetInitialConstraintsForHelper::operator() (const Resolvent & resolvent) const
auto i(_imp->initial_constraints.find(resolvent));
if (i == _imp->initial_constraints.end())
return _make_initial_constraints_for(resolvent);
- else
- return i->second;
+ return i->second;
}
namespace
@@ -183,36 +182,27 @@ namespace
return (current_time.seconds() - installed_time) > (24 * 60 * 60 * n);
}
- else
- return false;
+ return false;
}
- bool installed_is_scm_older_than(
- const Environment * const env,
- const Resolvent & q,
- const int n)
+ bool installed_is_scm_older_than(const Environment * const env,
+ const Resolvent & r, const int n)
{
- Context context("When working out whether '" + stringify(q) + "' has installed SCM packages:");
+ Context context("When working out whether '" + stringify(r) + "' has installed SCM packages:");
- const std::shared_ptr<const PackageIDSequence> ids((*env)[selection::AllVersionsUnsorted(
- destination_filtered_generator(env, q.destination_type(), generator::Package(q.package())) |
- make_slot_filter(q)
- )]);
+ const std::shared_ptr<const PackageIDSequence> ids =
+ (*env)[selection::AllVersionsUnsorted(destination_filtered_generator(env, r.destination_type(), generator::Package(r.package())) |
+ make_slot_filter(r))];
- for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
- i != i_end ; ++i)
- {
- if (is_scm_older_than(*i, n))
+ for (const auto & package : *ids)
+ if (is_scm_older_than(package, n))
return true;
- }
-
return false;
}
- bool use_existing_from_withish(
- const Environment * const env,
- const QualifiedPackageName & name,
- const std::list<PackageDepSpec> & list)
+ bool use_existing_from_withish(const Environment * const env,
+ const QualifiedPackageName & name,
+ const std::list<PackageDepSpec> & list)
{
for (const auto & l : list)
if (match_qpns(*env, l, name))
@@ -222,8 +212,7 @@ namespace
}
const std::shared_ptr<Constraints>
-GetInitialConstraintsForHelper::_make_initial_constraints_for(
- const Resolvent & resolvent) const
+GetInitialConstraintsForHelper::_make_initial_constraints_for(const Resolvent & resolvent) const
{
auto result(std::make_shared<Constraints>());
diff --git a/paludis/resolver/get_initial_constraints_for_helper.hh b/paludis/resolver/get_initial_constraints_for_helper.hh
index 5196a17..7e90c85 100644
--- a/paludis/resolver/get_initial_constraints_for_helper.hh
+++ b/paludis/resolver/get_initial_constraints_for_helper.hh
@@ -55,8 +55,7 @@ namespace paludis
void set_reinstall_scm_days(const int);
- const std::shared_ptr<Constraints> operator() (
- const Resolvent &) const;
+ const std::shared_ptr<Constraints> operator()(const Resolvent &) const;
};
}
diff --git a/paludis/resolver/interest_in_spec_helper.cc b/paludis/resolver/interest_in_spec_helper.cc
index 54a1cb9..df68f8a 100644
--- a/paludis/resolver/interest_in_spec_helper.cc
+++ b/paludis/resolver/interest_in_spec_helper.cc
@@ -247,10 +247,9 @@ namespace
}
SpecInterest
-InterestInSpecHelper::operator() (
- const std::shared_ptr<const Resolution> & resolution,
- const std::shared_ptr<const PackageID> & id,
- const SanitisedDependency & dep) const
+InterestInSpecHelper::operator() (const std::shared_ptr<const Resolution> & resolution,
+ const std::shared_ptr<const PackageID> & id,
+ const SanitisedDependency & dep) const
{
Context context("When determining interest in '" + stringify(dep.spec()) + "':");
@@ -265,19 +264,13 @@ InterestInSpecHelper::operator() (
return si_take;
if (dep.spec().if_package())
- {
- for (auto l(_imp->take_specs.begin()), l_end(_imp->take_specs.end()) ;
- l != l_end ; ++l)
- if (match_qpns(*_imp->env, *l, *dep.spec().if_package()->package_ptr()))
+ for (const auto & spec : _imp->take_specs)
+ if (match_qpns(*_imp->env, spec, *dep.spec().if_package()->package_ptr()))
return si_take;
- }
- for (auto l(_imp->take_from_specs.begin()), l_end(_imp->take_from_specs.end()) ;
- l != l_end ; ++l)
- {
- if (match_package(*_imp->env, *l, id, nullptr, { }))
+ for (const auto & spec : _imp->take_from_specs)
+ if (match_package(*_imp->env, spec, id, nullptr, { }))
return si_take;
- }
std::string spec_group;
{
@@ -294,19 +287,13 @@ InterestInSpecHelper::operator() (
return si_take;
if (dep.spec().if_package())
- {
- for (auto l(_imp->ignore_specs.begin()), l_end(_imp->ignore_specs.end()) ;
- l != l_end ; ++l)
- if (match_qpns(*_imp->env, *l, *dep.spec().if_package()->package_ptr()))
+ for (const auto & spec : _imp->ignore_specs)
+ if (match_qpns(*_imp->env, spec, *dep.spec().if_package()->package_ptr()))
return si_ignore;
- }
- for (auto l(_imp->ignore_from_specs.begin()), l_end(_imp->ignore_from_specs.end()) ;
- l != l_end ; ++l)
- {
- if (match_package(*_imp->env, *l, id, nullptr, { }))
+ for (const auto & spec : _imp->ignore_from_specs)
+ if (match_package(*_imp->env, spec, id, nullptr, { }))
return si_ignore;
- }
if ((! spec_group.empty()) && _imp->ignore_groups.end() != _imp->ignore_groups.find(spec_group))
return si_ignore;
@@ -314,10 +301,9 @@ InterestInSpecHelper::operator() (
/* we also take suggestions and recommendations that have already been installed */
if (dep.spec().if_package())
{
- const std::shared_ptr<const PackageIDSequence> installed_ids(
- (*_imp->env)[selection::SomeArbitraryVersion(
- generator::Matches(*dep.spec().if_package(), dep.from_id(), { }) |
- filter::InstalledAtRoot(_imp->env->system_root_key()->parse_value()))]);
+ const std::shared_ptr<const PackageIDSequence> installed_ids =
+ (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*dep.spec().if_package(), dep.from_id(), {}) |
+ filter::InstalledAtRoot(_imp->env->system_root_key()->parse_value()))];
if (! installed_ids->empty())
return si_take;
}
@@ -349,8 +335,8 @@ InterestInSpecHelper::operator() (
return si_untaken;
}
- else
- return si_ignore;
+
+ return si_ignore;
}
namespace paludis
diff --git a/paludis/resolver/make_destination_filtered_generator_helper.cc b/paludis/resolver/make_destination_filtered_generator_helper.cc
index e8d7237..27b9d99 100644
--- a/paludis/resolver/make_destination_filtered_generator_helper.cc
+++ b/paludis/resolver/make_destination_filtered_generator_helper.cc
@@ -43,8 +43,7 @@ namespace paludis
{
const Environment * const env;
- Imp(const Environment * const e) :
- env(e)
+ Imp(const Environment * const e) : env(e)
{
}
};
@@ -58,9 +57,8 @@ MakeDestinationFilteredGeneratorHelper::MakeDestinationFilteredGeneratorHelper(c
MakeDestinationFilteredGeneratorHelper::~MakeDestinationFilteredGeneratorHelper() = default;
FilteredGenerator
-MakeDestinationFilteredGeneratorHelper::operator() (
- const Generator & g,
- const std::shared_ptr<const Resolution> & r) const
+MakeDestinationFilteredGeneratorHelper::operator()(const Generator & g,
+ const std::shared_ptr<const Resolution> & r) const
{
return destination_filtered_generator(_imp->env, r->resolvent().destination_type(), g);
}
diff --git a/paludis/resolver/make_destination_filtered_generator_helper.hh b/paludis/resolver/make_destination_filtered_generator_helper.hh
index 179537b..c68a116 100644
--- a/paludis/resolver/make_destination_filtered_generator_helper.hh
+++ b/paludis/resolver/make_destination_filtered_generator_helper.hh
@@ -42,9 +42,8 @@ namespace paludis
explicit MakeDestinationFilteredGeneratorHelper(const Environment * const);
~MakeDestinationFilteredGeneratorHelper();
- FilteredGenerator operator() (
- const Generator &,
- const std::shared_ptr<const Resolution> &) const;
+ FilteredGenerator operator()(const Generator &,
+ const std::shared_ptr<const Resolution> &) const;
};
}
diff --git a/paludis/resolver/remove_if_dependent_helper.cc b/paludis/resolver/remove_if_dependent_helper.cc
index 1dea571..efe25b9 100644
--- a/paludis/resolver/remove_if_dependent_helper.cc
+++ b/paludis/resolver/remove_if_dependent_helper.cc
@@ -37,9 +37,7 @@ namespace paludis
const Environment * const env;
PackageDepSpecCollection remove_if_dependent_specs;
- Imp(const Environment * const e) :
- env(e),
- remove_if_dependent_specs(nullptr)
+ Imp(const Environment * const e) : env(e), remove_if_dependent_specs(nullptr)
{
}
};
@@ -59,8 +57,7 @@ RemoveIfDependentHelper::add_remove_if_dependent_spec(const PackageDepSpec & spe
}
bool
-RemoveIfDependentHelper::operator() (
- const std::shared_ptr<const PackageID> & id) const
+RemoveIfDependentHelper::operator()(const std::shared_ptr<const PackageID> & id) const
{
return _imp->remove_if_dependent_specs.match_any(_imp->env, id, { });
}
diff --git a/paludis/resolver/remove_if_dependent_helper.hh b/paludis/resolver/remove_if_dependent_helper.hh
index 55752e2..e0052a6 100644
--- a/paludis/resolver/remove_if_dependent_helper.hh
+++ b/paludis/resolver/remove_if_dependent_helper.hh
@@ -44,8 +44,7 @@ namespace paludis
void add_remove_if_dependent_spec(const PackageDepSpec &);
- bool operator() (
- const std::shared_ptr<const PackageID> &) const;
+ bool operator()(const std::shared_ptr<const PackageID> &) const;
};
}