commit:     60adb5cada59cd9e7374b0aee44237760ee6dc30
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 20:33:16 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 20:33:16 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=60adb5ca

qsize: use cached tree for multiple lookups

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

 qsize.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/qsize.c b/qsize.c
index c78a35f..391d357 100644
--- a/qsize.c
+++ b/qsize.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2026 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <[email protected]>
@@ -254,7 +254,13 @@ int qsize_main(int argc, char **argv)
        if (vdb != NULL) {
                if (array_cnt(atoms) > 0) {
                        array_for_each(atoms, i, atom) {
-                               ret = tree_foreach_pkg_fast(vdb, qsize_cb, 
&state, atom);
+                               if (atom->CATEGORY == NULL &&
+                                       i + 1 < array_cnt(atoms))
+                               {
+                                       ret = tree_foreach_pkg_cached(vdb, 
qsize_cb, &state, atom);
+                               } else {
+                                       ret = tree_foreach_pkg_fast(vdb, 
qsize_cb, &state, atom);
+                               }
                        }
                } else {
                        ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, 
NULL);

Reply via email to