Skip to content

Commit 7753695

Browse files
committed
lib: replace array iterator with for loop in get_pkg_in_array
1 parent d973a8d commit 7753695

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/plist_find.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,20 @@
3737
static xbps_dictionary_t
3838
get_pkg_in_array(xbps_array_t array, const char *str, xbps_trans_type_t tt, bool virtual)
3939
{
40-
xbps_object_t obj;
41-
xbps_object_iterator_t iter;
40+
xbps_object_t obj = NULL;
4241
xbps_trans_type_t ttype;
4342
bool found = false;
4443

4544
assert(array);
4645
assert(str);
4746

48-
iter = xbps_array_iterator(array);
49-
if (!iter)
50-
return NULL;
51-
52-
while ((obj = xbps_object_iterator_next(iter))) {
47+
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
5348
const char *pkgver = NULL;
5449
char pkgname[XBPS_NAME_SIZE] = {0};
5550

56-
if (!xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver)) {
57-
continue;
58-
}
51+
obj = xbps_array_get(array, i);
52+
if (!xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver))
53+
abort();
5954
if (virtual) {
6055
/*
6156
* Check if package pattern matches
@@ -87,7 +82,6 @@ get_pkg_in_array(xbps_array_t array, const char *str, xbps_trans_type_t tt, bool
8782
}
8883
}
8984
}
90-
xbps_object_iterator_release(iter);
9185

9286
ttype = xbps_transaction_pkg_type(obj);
9387
if (found && tt && (ttype != tt)) {

0 commit comments

Comments
 (0)