commit:     d0d205c64d76c416eb83422828e30aea544f4591
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 13:34:16 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 13:34:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d0d205c6

qsize: push query atoms down to tree_foreach_pkg

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/qsize.c b/qsize.c
index 1f1dfc9..5cf7dae 100644
--- a/qsize.c
+++ b/qsize.c
@@ -109,22 +109,6 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        FILE *fp;
        size_t num_files, num_nonfiles, num_ignored;
        uint64_t num_bytes;
-       bool showit = false;
-
-       /* see if this cat/pkg is requested */
-       if (array_cnt(state->atoms)) {
-               depend_atom *qatom;
-
-               qatom = tree_get_atom(pkg_ctx, 0);
-               array_for_each(state->atoms, i, atom)
-                       if (atom_compare(qatom, atom) == EQUAL) {
-                               showit = true;
-                               break;
-                       }
-       } else
-               showit = true;
-       if (!showit)
-               return EXIT_SUCCESS;
 
        if ((fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
                return EXIT_SUCCESS;
@@ -248,7 +232,13 @@ int qsize_main(int argc, char **argv)
 
        vdb = tree_open_vdb(portroot, portvdb);
        if (vdb != NULL) {
-               ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, NULL);
+               if (array_cnt(atoms) > 0) {
+                       array_for_each(atoms, i, atom) {
+                               ret = tree_foreach_pkg_fast(vdb, qsize_cb, 
&state, atom);
+                       }
+               } else {
+                       ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, 
NULL);
+               }
                tree_close(vdb);
        }
 

Reply via email to