Performance improvements for xbps_find_pkg_in_dict_by_{name,pattern} with virtual pkgs.
This commit is contained in:
parent
080334da8b
commit
93e1a0a22c
14
lib/plist.c
14
lib/plist.c
@ -234,19 +234,15 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static prop_dictionary_t
|
static prop_dictionary_t
|
||||||
find_virtual_pkg_in_dict(prop_dictionary_t d,
|
find_virtual_pkg_in_dict(prop_object_iterator_t iter,
|
||||||
const char *key,
|
|
||||||
const char *str,
|
const char *str,
|
||||||
bool bypattern)
|
bool bypattern)
|
||||||
{
|
{
|
||||||
prop_object_iterator_t iter;
|
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_array_t provides;
|
prop_array_t provides;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if ((iter = xbps_get_array_iter_from_dict(d, key)) == NULL)
|
prop_object_iterator_reset(iter);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
if ((provides = prop_dictionary_get(obj, "provides")) == NULL)
|
if ((provides = prop_dictionary_get(obj, "provides")) == NULL)
|
||||||
continue;
|
continue;
|
||||||
@ -294,22 +290,22 @@ find_pkg_in_dict(prop_dictionary_t d,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
/*
|
/*
|
||||||
* No pkg was found, try virtual package by name
|
* No pkg was found, try virtual package by name
|
||||||
* or by pattern.
|
* or by pattern.
|
||||||
*/
|
*/
|
||||||
if (bypattern)
|
if (bypattern)
|
||||||
obj = find_virtual_pkg_in_dict(d, key, str, true);
|
obj = find_virtual_pkg_in_dict(iter, str, true);
|
||||||
else
|
else
|
||||||
obj = find_virtual_pkg_in_dict(d, key, str, false);
|
obj = find_virtual_pkg_in_dict(iter, str, false);
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user