xbps_sort_pkg_deps: exit from the loop immediately if all pkgs were sorted.

This commit is contained in:
Juan RP 2011-01-25 16:04:37 +01:00
parent a47d030851
commit a685c9ee41

View File

@ -99,6 +99,10 @@ again:
* Order all deps by looking at its run_depends array. * Order all deps by looking at its run_depends array.
*/ */
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = prop_object_iterator_next(iter)) != NULL) {
/* no more iterations required, pkglist is sorted */
if (cnt >= ndeps)
break;
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dbg_printf("Sorting package '%s': ", pkgver); xbps_dbg_printf("Sorting package '%s': ", pkgver);
@ -108,7 +112,7 @@ again:
done = false; done = false;
prop_dictionary_get_bool(obj, "sorted", &done); prop_dictionary_get_bool(obj, "sorted", &done);
if (done) { if (done) {
xbps_dbg_printf_append("skipping, already queued.\n", xbps_dbg_printf_append("skipping, already sorted.\n",
pkgname); pkgname);
continue; continue;
} }
@ -130,13 +134,11 @@ again:
rv = ENOMEM; rv = ENOMEM;
goto out; goto out;
} }
xbps_dbg_printf_append("\n");
/* /*
* Iterate over the run_depends array, and find out if they * Iterate over the run_depends array, and find out if they
* were already added in the sorted list. * were already added in the sorted list.
*/ */
xbps_dbg_printf_append("\n");
xbps_dbg_printf("Checking '%s' run depends for sorting...\n",
pkgver);
while ((obj2 = prop_object_iterator_next(iter2)) != NULL) { while ((obj2 = prop_object_iterator_next(iter2)) != NULL) {
str = prop_string_cstring_nocopy(obj2); str = prop_string_cstring_nocopy(obj2);
if (str == NULL) { if (str == NULL) {
@ -172,13 +174,13 @@ again:
prop_array_add(sorted, obj); prop_array_add(sorted, obj);
prop_dictionary_set_bool(obj, "sorted", true); prop_dictionary_set_bool(obj, "sorted", true);
xbps_dbg_printf("Added package '%s' to the sorted " xbps_dbg_printf("Added package '%s' to the sorted "
"queue (all rundeps satisfied).\n\n", pkgver); "queue (all rundeps satisfied).\n", pkgver);
rundepscnt = 0; rundepscnt = 0;
cnt++; cnt++;
continue; continue;
} }
xbps_dbg_printf("Unsorted package '%s' has missing " xbps_dbg_printf("Unsorted package '%s' has missing "
"rundeps (missing %zu).\n\n", pkgver, "rundeps (missing %zu).\n", pkgver,
prop_array_count(rundeps) - rundepscnt); prop_array_count(rundeps) - rundepscnt);
rundepscnt = 0; rundepscnt = 0;
} }
@ -187,7 +189,6 @@ again:
xbps_dbg_printf("Missing required deps! queued: %zu " xbps_dbg_printf("Missing required deps! queued: %zu "
"required: %zu.\n", cnt, ndeps); "required: %zu.\n", cnt, ndeps);
prop_object_iterator_reset(iter); prop_object_iterator_reset(iter);
xbps_dbg_printf("total iteratons %zu\n", cnt);
goto again; goto again;
} }
prop_object_iterator_release(iter); prop_object_iterator_release(iter);