Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] similar_name_search: used indexed repos where appropriate (bug 556764)
Date: Thu, 06 Aug 2015 06:09:51
Message-Id: 20150805230941.7a6b6305.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] similar_name_search: used indexed repos where appropriate (bug 556764) by Zac Medico
1 On Wed, 5 Aug 2015 22:09:59 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > This reduces the time of 'emerge --info foo' by roughly 24% on my
5 > laptop.
6 >
7 > X-Gentoo-Bug: 556764
8 > X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=556764
9 > ---
10 > pym/_emerge/actions.py | 7 +++++--
11 > pym/_emerge/depgraph.py | 6 +++++-
12 > 2 files changed, 10 insertions(+), 3 deletions(-)
13 >
14 > diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
15 > index 92d1f2e..01aef51 100644
16 > --- a/pym/_emerge/actions.py
17 > +++ b/pym/_emerge/actions.py
18 > @@ -42,6 +42,8 @@ from portage.const import GLOBAL_CONFIG_PATH,
19 > VCS_DIRS, _DEPCLEAN_LIB_CHECK_DEFA from portage.const import
20 > SUPPORTED_BINPKG_FORMATS, TIMESTAMP_FORMAT from
21 > portage.dbapi.dep_expand import dep_expand from
22 > portage.dbapi._expand_new_virt import expand_new_virt +from
23 > portage.dbapi.IndexedPortdb import IndexedPortdb +from
24 > portage.dbapi.IndexedVardb import IndexedVardb from portage.dep
25 > import Atom, _repo_separator, _slot_separator from
26 > portage.eclass_cache import hashed_path from portage.exception import
27 > InvalidAtom, InvalidData, ParseError @@ -1513,9 +1515,10 @@ def
28 > action_info(settings, trees, myopts, myfiles): writemsg("\nemerge:
29 > searching for similar names..." , noiselevel=-1)
30 >
31 > - dbs = [vardb]
32 > + search_index =
33 > myopts.get("--search-index", "y") != "n"
34 > + dbs = [IndexedVardb(vardb) if
35 > search_index else vardb] #if "--usepkgonly" not in myopts:
36 > - dbs.append(portdb)
37 > + dbs.append(IndexedPortdb(portdb) if
38 > search_index else portdb) if "--usepkg" in myopts:
39 > dbs.append(bindb)
40 >
41 > diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
42 > index a957108..57040ab 100644
43 > --- a/pym/_emerge/depgraph.py
44 > +++ b/pym/_emerge/depgraph.py
45 > @@ -21,6 +21,7 @@ from portage.const import PORTAGE_PACKAGE_ATOM,
46 > USER_CONFIG_PATH, VCS_DIRS from portage.dbapi import dbapi
47 > from portage.dbapi.dep_expand import dep_expand
48 > from portage.dbapi.DummyTree import DummyTree
49 > +from portage.dbapi.IndexedPortdb import IndexedPortdb
50 > from portage.dbapi._similar_name_search import similar_name_search
51 > from portage.dep import Atom, best_match_to_list,
52 > extract_affecting_use, \ check_required_use,
53 > human_readable_required_use, match_from_list, \ @@ -5100,10 +5101,13
54 > @@ class depgraph(object): writemsg("\nemerge: searching for similar
55 > names..." , noiselevel=-1)
56 >
57 > + search_index =
58 > self._frozen_config.myopts.get("--search-index", "y") != "n"
59 > + # fakedbapi is indexed
60 > dbs = [vardb]
61 > if "--usepkgonly" not in
62 > self._frozen_config.myopts:
63 > - dbs.append(portdb)
64 > +
65 > dbs.append(IndexedPortdb(portdb) if search_index else portdb) if
66 > "--usepkg" in self._frozen_config.myopts:
67 > + # bindbapi is indexed
68 > dbs.append(bindb)
69 >
70 > matches = similar_name_search(dbs,
71 > atom)
72
73 looks good
74
75 --
76 Brian Dolbec <dolsen>