aboutsummaryrefslogtreecommitdiff
path: root/paludis/environment_implementation.cc
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-02-24 19:27:49 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-03-02 08:59:13 -0800
commitc688a4d80b8283dc35e032d24086205c01a0b2c9 (patch)
treee19023be8c3365c0c566d9a6e7021f6b607b386e /paludis/environment_implementation.cc
parent0ce8ee0e8a9109d043697b7e3402fe12d7ee7542 (diff)
downloadpaludis-c688a4d80b8283dc35e032d24086205c01a0b2c9.tar.gz
paludis-c688a4d80b8283dc35e032d24086205c01a0b2c9.tar.xz
remove unexecuted statements
This reworks some idiom usage to avoid unexecutable statements. This is a code cleanup of locations flagged by the clang parser. No functionality change is intended.
Diffstat (limited to 'paludis/environment_implementation.cc')
-rw-r--r--paludis/environment_implementation.cc86
1 files changed, 45 insertions, 41 deletions
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index a47a3dc07..fd33168a1 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -483,6 +483,50 @@ namespace
return ! _map->find(qpn)->second.second;
}
};
+
+ void disambiguate_package_from(const PackageNamePart & p,
+ std::list<QualifiedPackageName> & qpns,
+ const EnvironmentImplementation * const env,
+ const std::shared_ptr<QPNIMap> & result)
+ {
+ using namespace std::placeholders;
+
+ const IsImportant is_important(result);
+ const IsInstalled is_installed(env);
+ const IsInUnimportantRepo is_in_unimportant_repo(result);
+
+ std::remove_copy_if(first_iterator(result->begin()),
+ first_iterator(result->end()),
+ std::front_inserter(qpns),
+ std::bind(std::logical_and<bool>(),
+ std::bind(std::not1(is_important), _1),
+ std::bind(std::not1(is_installed), _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(is_in_unimportant_repo, _1));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(std::logical_and<bool>(),
+ std::bind(is_important, _1),
+ std::bind(std::not1(is_installed), _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ qpns.remove_if(std::bind(std::logical_and<bool>(),
+ std::bind(std::not1(is_important), _1),
+ std::bind(is_installed, _1)));
+ if (! qpns.empty() && next(qpns.begin()) == qpns.end())
+ return;
+
+ auto candidates(std::make_shared<Sequence<std::string> >());
+ std::transform(first_iterator(result->begin()),
+ first_iterator(result->end()),
+ candidates->back_inserter(),
+ &stringify<QualifiedPackageName>);
+ throw AmbiguousPackageNameError(stringify(p), candidates);
+ }
}
QualifiedPackageName
@@ -523,49 +567,9 @@ EnvironmentImplementation::fetch_unique_qualified_package_name(const PackageName
throw NoSuchPackageError(stringify(p));
if (result->size() > 1)
{
- using namespace std::placeholders;
-
std::list<QualifiedPackageName> qpns;
- do
- {
- const IsImportant is_important(result);
- const IsInstalled is_installed(this);
- const IsInUnimportantRepo is_in_unimportant_repo(result);
-
- std::remove_copy_if(first_iterator(result->begin()), first_iterator(result->end()),
- std::front_inserter(qpns),
- std::bind(std::logical_and<bool>(),
- std::bind(std::not1(is_important), _1),
- std::bind(std::not1(is_installed), _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(is_in_unimportant_repo, _1));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(std::logical_and<bool>(),
- std::bind(is_important, _1),
- std::bind(std::not1(is_installed), _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- qpns.remove_if(std::bind(std::logical_and<bool>(),
- std::bind(std::not1(is_important), _1),
- std::bind(is_installed, _1)));
-
- if (! qpns.empty() && next(qpns.begin()) == qpns.end())
- break;
-
- auto candidates(std::make_shared<Sequence<std::string> >());
- std::transform(first_iterator(result->begin()), first_iterator(result->end()), candidates->back_inserter(),
- &stringify<QualifiedPackageName>);
- throw AmbiguousPackageNameError(stringify(p), candidates);
- } while (false);
+ disambiguate_package_from(p, qpns, this, result);
if (! disambiguate)
{