Minor optimization: no need to check if obj is NULL, prop_object_type() does that already.

This commit is contained in:
Juan RP 2013-06-14 12:22:29 +02:00
parent 9c44411722
commit 9d80524a34
12 changed files with 14 additions and 32 deletions

View File

@ -45,7 +45,7 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
assert(entry_pname != NULL);
array = prop_dictionary_get(propsd, "conf_files");
if (array == NULL || prop_array_count(array) == 0)
if (prop_array_count(array) == 0)
return false;
for (i = 0; i < prop_array_count(array); i++) {

View File

@ -44,7 +44,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
char *pkgname, *repopkgname, *buf;
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts");
if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0)
if (prop_array_count(pkg_cflicts) == 0)
return;
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts");

View File

@ -107,8 +107,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, curpkgver);
cnt = prop_array_count(reqby);
if (reqby == NULL || (cnt == 0)) {
if (prop_array_count(reqby) == 0) {
/*
* Add packages with empty revdeps.
*/
@ -124,8 +123,6 @@ find_orphans:
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
rdeps = prop_dictionary_get(pkgd, "run_depends");
if (rdeps == NULL)
continue;
for (x = 0; x < prop_array_count(rdeps); x++) {
cnt = 0;
prop_array_get_cstring_nocopy(rdeps, x, &deppkgver);

View File

@ -52,8 +52,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
assert(key != NULL);
array = prop_dictionary_get(dict, key);
if ((prop_object_type(array) != PROP_TYPE_ARRAY) ||
prop_array_count(array) == 0)
if (prop_array_count(array) == 0)
return 0;
iter = xbps_array_iter_from_dict(dict, key);

View File

@ -64,8 +64,6 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file)
assert(d);
links = prop_dictionary_get(d, "links");
assert(links);
for (i = 0; i < prop_array_count(links); i++) {
rfile = strchr(file, '.') + 1;
obj = prop_array_get(links, i);
@ -96,16 +94,16 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
/* Add objects from XBPS_PKGFILES */
array = prop_dictionary_get(filesd, "files");
if (array && prop_array_count(array))
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "files", array);
array = prop_dictionary_get(filesd, "conf_files");
if (array && prop_array_count(array))
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "conf_files", array);
array = prop_dictionary_get(filesd, "links");
if (array && prop_array_count(array))
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "links", array);
array = prop_dictionary_get(filesd, "dirs");
if (array && prop_array_count(array))
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "dirs", array);
/* Add install/remove scripts data objects */

View File

@ -151,8 +151,6 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
return rv;
allkeys = prop_dictionary_all_keys(xhp->pkgdb);
assert(allkeys);
for (i = prop_array_count(allkeys); i > 0; i--) {
obj = prop_array_get(allkeys, i);
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
@ -267,7 +265,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = prop_dictionary_get(pkgd, "run_depends");
if (rundeps == NULL || !prop_array_count(rundeps))
if (!prop_array_count(rundeps))
continue;
for (i = 0; i < prop_array_count(rundeps); i++) {

View File

@ -120,9 +120,6 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
assert(fn != NULL);
array = prop_dictionary_get(dict, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY)
return ENOENT;
for (i = 0; i < prop_array_count(array); i++) {
obj = prop_array_get(array, i);
if (obj == NULL)

View File

@ -226,7 +226,7 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
continue;
pkgdeps = prop_dictionary_get(pkgd, "run_depends");
if (pkgdeps == NULL || !prop_array_count(pkgdeps))
if (!prop_array_count(pkgdeps))
continue;
/*
* Try to match passed in string.

View File

@ -392,9 +392,7 @@ xbps_repository_find_deps(struct xbps_handle *xhp,
unsigned short depth = 0;
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends");
if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY)
return 0;
else if (prop_array_count(pkg_rdeps) == 0)
if (prop_array_count(pkg_rdeps) == 0)
return 0;
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);

View File

@ -355,11 +355,7 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
int rv = 0;
orphans = xbps_find_pkg_orphans(xhp, NULL);
if (prop_object_type(orphans) != PROP_TYPE_ARRAY)
return EINVAL;
count = prop_array_count(orphans);
if (count == 0) {
if ((count = prop_array_count(orphans)) == 0) {
/* no orphans? we are done */
rv = ENOENT;
goto out;

View File

@ -344,7 +344,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* it doesn't matter.
*/
rundeps = prop_dictionary_get(obj, "run_depends");
if (rundeps == NULL || prop_array_count(rundeps) == 0) {
if (prop_array_count(rundeps) == 0) {
xbps_dbg_printf_append(xhp, "\n");
cnt++;
continue;

View File

@ -215,8 +215,7 @@ xbps_pkg_has_rundeps(prop_dictionary_t pkgd)
assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY);
array = prop_dictionary_get(pkgd, "run_depends");
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
prop_array_count(array) > 0)
if (prop_array_count(array))
return true;
return false;