From 5d3e701b3a40b7b7bff8db0f0b1f564a46a0c803 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 29 Dec 2008 07:01:01 +0100 Subject: [PATCH] Simplify xbps_get_dependency(). --HG-- extra : convert_revision : 2174be8c7c6386f403a3d2d96c8443629fa6db21 --- lib/depends.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index 40d09427a95..77bc084d74a 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -114,7 +114,6 @@ xbps_get_dependency(void) { struct pkg_dependency *dep = NULL; uint64_t reqcount = 0 , priority = 0; - bool depfound = false; /* Set max reqcount and priority found */ SIMPLEQ_FOREACH(dep, &pkg_deps, deps) { @@ -125,35 +124,25 @@ xbps_get_dependency(void) } /* Pass 1: return pkgs with highest reqcount and priority */ - SIMPLEQ_FOREACH(dep, &pkg_deps, deps) { - if (dep->reqcount == reqcount && dep->priority == priority) { - depfound = true; + SIMPLEQ_FOREACH(dep, &pkg_deps, deps) + if (dep->reqcount == reqcount && dep->priority == priority) goto out; - } - } /* Pass 2: return pkgs with highest priority */ - SIMPLEQ_FOREACH(dep, &pkg_deps, deps) { - if (dep->priority == priority) { - depfound = true; + SIMPLEQ_FOREACH(dep, &pkg_deps, deps) + if (dep->priority == priority) goto out; - } - } /* Pass 3: return pkgs with highest reqcount */ - SIMPLEQ_FOREACH(dep, &pkg_deps, deps) { - if (dep->reqcount == reqcount) { - depfound = true; + SIMPLEQ_FOREACH(dep, &pkg_deps, deps) + if (dep->reqcount == reqcount) goto out; - } - } /* Last pass: return pkgs with default reqcount/priority */ dep = SIMPLEQ_FIRST(&pkg_deps); - depfound = true; out: - if (depfound && dep != NULL) { + if (dep != NULL) { /* * Remove dep from queue, it will be freed later with * xbps_destroy_dependency().