commit: c7e04780a3161d6e8785c175680751839f9d768b
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 16:40:50 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 16:40:50 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7e04780
qgrep: use tree_get_atom
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
qgrep.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/qgrep.c b/qgrep.c
index 8e240f3..2db61df 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -391,9 +391,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
int ret;
int pfd;
- snprintf(buf, sizeof(buf), "%s/%s",
- pkg_ctx->cat_ctx->name, pkg_ctx->name);
- patom = atom_explode(buf);
+ patom = tree_get_atom(pkg_ctx, false);
if (patom == NULL)
return EXIT_FAILURE;
@@ -403,10 +401,8 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
if (atom_compare(patom, *d) == EQUAL)
break;
}
- if (*d == NULL) {
- atom_implode(patom);
+ if (*d == NULL)
return EXIT_FAILURE;
- }
}
/* need to construct path in portdir to ebuild, pass it to grep */
@@ -423,6 +419,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
label = NULL;
if (data->show_name) {
+ /* this is a super-optimisation, should get it from the full
atom */
char *repo = data->show_repo ? cctx->repo : NULL;
snprintf(name, sizeof(name), "%s%s/%s%s%s%s%s%s",
BOLD, patom->CATEGORY, BLUE, patom->P, GREEN,
@@ -434,8 +431,6 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
ret = qgrep_grepat(pfd, buf, label, data);
- atom_implode(patom);
-
return ret;
}
@@ -450,9 +445,7 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv)
int ret;
int pfd;
- snprintf(buf, sizeof(buf), "%s/%s",
- pkg_ctx->cat_ctx->name, pkg_ctx->name);
- patom = atom_explode(buf);
+ patom = tree_get_atom(pkg_ctx, false);
if (patom == NULL)
return EXIT_FAILURE;
@@ -487,8 +480,6 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv)
ret = qgrep_grepat(pfd, buf, label, data);
- atom_implode(patom);
-
return ret;
}