1 |
commit: c7e04780a3161d6e8785c175680751839f9d768b |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri May 10 16:40:50 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 10 16:40:50 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7e04780 |
7 |
|
8 |
qgrep: use tree_get_atom |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qgrep.c | 17 ++++------------- |
13 |
1 file changed, 4 insertions(+), 13 deletions(-) |
14 |
|
15 |
diff --git a/qgrep.c b/qgrep.c |
16 |
index 8e240f3..2db61df 100644 |
17 |
--- a/qgrep.c |
18 |
+++ b/qgrep.c |
19 |
@@ -391,9 +391,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
20 |
int ret; |
21 |
int pfd; |
22 |
|
23 |
- snprintf(buf, sizeof(buf), "%s/%s", |
24 |
- pkg_ctx->cat_ctx->name, pkg_ctx->name); |
25 |
- patom = atom_explode(buf); |
26 |
+ patom = tree_get_atom(pkg_ctx, false); |
27 |
if (patom == NULL) |
28 |
return EXIT_FAILURE; |
29 |
|
30 |
@@ -403,10 +401,8 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
31 |
if (atom_compare(patom, *d) == EQUAL) |
32 |
break; |
33 |
} |
34 |
- if (*d == NULL) { |
35 |
- atom_implode(patom); |
36 |
+ if (*d == NULL) |
37 |
return EXIT_FAILURE; |
38 |
- } |
39 |
} |
40 |
|
41 |
/* need to construct path in portdir to ebuild, pass it to grep */ |
42 |
@@ -423,6 +419,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
43 |
|
44 |
label = NULL; |
45 |
if (data->show_name) { |
46 |
+ /* this is a super-optimisation, should get it from the full atom */ |
47 |
char *repo = data->show_repo ? cctx->repo : NULL; |
48 |
snprintf(name, sizeof(name), "%s%s/%s%s%s%s%s%s", |
49 |
BOLD, patom->CATEGORY, BLUE, patom->P, GREEN, |
50 |
@@ -434,8 +431,6 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
51 |
|
52 |
ret = qgrep_grepat(pfd, buf, label, data); |
53 |
|
54 |
- atom_implode(patom); |
55 |
- |
56 |
return ret; |
57 |
} |
58 |
|
59 |
@@ -450,9 +445,7 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
60 |
int ret; |
61 |
int pfd; |
62 |
|
63 |
- snprintf(buf, sizeof(buf), "%s/%s", |
64 |
- pkg_ctx->cat_ctx->name, pkg_ctx->name); |
65 |
- patom = atom_explode(buf); |
66 |
+ patom = tree_get_atom(pkg_ctx, false); |
67 |
if (patom == NULL) |
68 |
return EXIT_FAILURE; |
69 |
|
70 |
@@ -487,8 +480,6 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
71 |
|
72 |
ret = qgrep_grepat(pfd, buf, label, data); |
73 |
|
74 |
- atom_implode(patom); |
75 |
- |
76 |
return ret; |
77 |
} |