Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH 01/14] Use public API: hashfunc_map -> get_valid_checksum_keys()
Date: Sun, 12 Mar 2017 21:13:34
Message-Id: 1489353207.609.0.camel@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 01/14] Use public API: hashfunc_map -> get_valid_checksum_keys() by Zac Medico
1 W dniu 12.03.2017, nie o godzinie 13∶36 -0700, użytkownik Zac Medico
2 napisał:
3 > On Sun, Mar 12, 2017 at 11:59 AM, Michał Górny <mgorny@g.o> wrote:
4 > > Use get_valid_checksum_keys() function instead of accessing hashfunc_map
5 > > directly throughout the Portage.
6 > > ---
7 > > pym/portage/_emirrordist/FetchTask.py | 2 +-
8 > > pym/portage/dbapi/bintree.py | 4 ++--
9 > > pym/portage/eclass_cache.py | 2 +-
10 > > pym/portage/manifest.py | 4 ++--
11 > > pym/portage/package/ebuild/fetch.py | 10 +++++-----
12 > > 5 files changed, 11 insertions(+), 11 deletions(-)
13 > >
14 > > diff --git a/pym/portage/_emirrordist/FetchTask.py b/pym/portage/_emirrordist/FetchTask.py
15 > > index 64de67582..203b8c213 100644
16 > > --- a/pym/portage/_emirrordist/FetchTask.py
17 > > +++ b/pym/portage/_emirrordist/FetchTask.py
18 > > @@ -574,7 +574,7 @@ class FetchTask(CompositeTask):
19 > > else:
20 > > for hash_name in self.digests:
21 > > if hash_name != "size" and \
22 > > - hash_name in portage.checksum.hashfunc_map:
23 > > + hash_name in portage.checksum.get_valid_checksum_keys():
24 >
25 > The get_valid_checksum_keys function creates a list for each call, so
26 > this is a lot less efficient that dict hash table lookup that it was
27 > before.
28
29 Does it really matter though? AFAICS this is just a matter of optimizing
30 the function, e.g. putting the keys in a frozenset.
31
32 --
33 Best regards,
34 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies