Simplify xbps_get_dependency().
--HG-- extra : convert_revision : 2174be8c7c6386f403a3d2d96c8443629fa6db21
This commit is contained in:
parent
e6590dd285
commit
5d3e701b3a
1 changed files with 7 additions and 18 deletions
|
@ -114,7 +114,6 @@ xbps_get_dependency(void)
|
||||||
{
|
{
|
||||||
struct pkg_dependency *dep = NULL;
|
struct pkg_dependency *dep = NULL;
|
||||||
uint64_t reqcount = 0 , priority = 0;
|
uint64_t reqcount = 0 , priority = 0;
|
||||||
bool depfound = false;
|
|
||||||
|
|
||||||
/* Set max reqcount and priority found */
|
/* Set max reqcount and priority found */
|
||||||
SIMPLEQ_FOREACH(dep, &pkg_deps, deps) {
|
SIMPLEQ_FOREACH(dep, &pkg_deps, deps) {
|
||||||
|
@ -125,35 +124,25 @@ xbps_get_dependency(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass 1: return pkgs with highest reqcount and priority */
|
/* Pass 1: return pkgs with highest reqcount and priority */
|
||||||
SIMPLEQ_FOREACH(dep, &pkg_deps, deps) {
|
SIMPLEQ_FOREACH(dep, &pkg_deps, deps)
|
||||||
if (dep->reqcount == reqcount && dep->priority == priority) {
|
if (dep->reqcount == reqcount && dep->priority == priority)
|
||||||
depfound = true;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pass 2: return pkgs with highest priority */
|
/* Pass 2: return pkgs with highest priority */
|
||||||
SIMPLEQ_FOREACH(dep, &pkg_deps, deps) {
|
SIMPLEQ_FOREACH(dep, &pkg_deps, deps)
|
||||||
if (dep->priority == priority) {
|
if (dep->priority == priority)
|
||||||
depfound = true;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pass 3: return pkgs with highest reqcount */
|
/* Pass 3: return pkgs with highest reqcount */
|
||||||
SIMPLEQ_FOREACH(dep, &pkg_deps, deps) {
|
SIMPLEQ_FOREACH(dep, &pkg_deps, deps)
|
||||||
if (dep->reqcount == reqcount) {
|
if (dep->reqcount == reqcount)
|
||||||
depfound = true;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Last pass: return pkgs with default reqcount/priority */
|
/* Last pass: return pkgs with default reqcount/priority */
|
||||||
dep = SIMPLEQ_FIRST(&pkg_deps);
|
dep = SIMPLEQ_FIRST(&pkg_deps);
|
||||||
depfound = true;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (depfound && dep != NULL) {
|
if (dep != NULL) {
|
||||||
/*
|
/*
|
||||||
* Remove dep from queue, it will be freed later with
|
* Remove dep from queue, it will be freed later with
|
||||||
* xbps_destroy_dependency().
|
* xbps_destroy_dependency().
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue