Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] config: cache profile.bashrc stat results (bug 649806)
Date: Sun, 15 Jul 2018 05:09:54
Message-Id: 20180715050555.4872-1-zmedico@gentoo.org
1 Optimize config to stat profile.bashrc files once in the constructor,
2 in order to avoid repeated stat calls in the setcpv method.
3
4 Bug: https://bugs.gentoo.org/649806
5 ---
6 pym/portage/package/ebuild/config.py | 13 ++++++++-----
7 1 file changed, 8 insertions(+), 5 deletions(-)
8
9 diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
10 index 88acac5cc..320d9f6c0 100644
11 --- a/pym/portage/package/ebuild/config.py
12 +++ b/pym/portage/package/ebuild/config.py
13 @@ -274,6 +274,7 @@ class config(object):
14 self.mycpv = clone.mycpv
15 self._setcpv_args_hash = clone._setcpv_args_hash
16 self._soname_provided = clone._soname_provided
17 + self._profile_bashrc = clone._profile_bashrc
18
19 # immutable attributes (internal policy ensures lack of mutation)
20 self._locations_manager = clone._locations_manager
21 @@ -725,6 +726,10 @@ class config(object):
22 self._license_manager.extract_global_changes( \
23 self.configdict["conf"].get("ACCEPT_LICENSE", ""))
24
25 + # profile.bashrc
26 + self._profile_bashrc = tuple(os.path.isfile(os.path.join(profile.location, 'profile.bashrc'))
27 + for profile in profiles_complex)
28 +
29 if local_config:
30 #package.properties
31 propdict = grabdict_package(os.path.join(
32 @@ -1596,11 +1601,9 @@ class config(object):
33
34 bashrc_files = []
35
36 - for profile in self._locations_manager.profiles_complex:
37 - profile_bashrc = os.path.join(profile.location,
38 - 'profile.bashrc')
39 - if os.path.exists(profile_bashrc):
40 - bashrc_files.append(profile_bashrc)
41 + for profile, profile_bashrc in zip(self._locations_manager.profiles_complex, self._profile_bashrc):
42 + if profile_bashrc:
43 + bashrc_files.append(os.path.join(profile.location, 'profile.bashrc'))
44 if profile in self._pbashrcdict:
45 cpdict = self._pbashrcdict[profile].get(cp)
46 if cpdict:
47 --
48 2.13.6

Replies