aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2018-07-14 21:54:45 -0700
committerZac Medico <zmedico@gentoo.org>2018-07-15 14:47:33 -0700
commit2de6ba26fd45fe942329ac928029e4edf603e125 (patch)
treeb25a32892471b863fffab640e10aba7c487bec44
parentportdbapi.xmatch: return separate items for each repo (diff)
downloadportage-2de6ba26fd45fe942329ac928029e4edf603e125.tar.gz
portage-2de6ba26fd45fe942329ac928029e4edf603e125.tar.bz2
portage-2de6ba26fd45fe942329ac928029e4edf603e125.zip
config: cache profile.bashrc stat results (bug 649806)
Optimize config to stat profile.bashrc files once in the constructor, in order to avoid repeated stat calls in the setcpv method. Bug: https://bugs.gentoo.org/649806 Reviewed-by: Brian Dolbec <dolsen@gentoo.org>
-rw-r--r--pym/portage/package/ebuild/config.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 88acac5cc..320d9f6c0 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -274,6 +274,7 @@ class config(object):
self.mycpv = clone.mycpv
self._setcpv_args_hash = clone._setcpv_args_hash
self._soname_provided = clone._soname_provided
+ self._profile_bashrc = clone._profile_bashrc
# immutable attributes (internal policy ensures lack of mutation)
self._locations_manager = clone._locations_manager
@@ -725,6 +726,10 @@ class config(object):
self._license_manager.extract_global_changes( \
self.configdict["conf"].get("ACCEPT_LICENSE", ""))
+ # profile.bashrc
+ self._profile_bashrc = tuple(os.path.isfile(os.path.join(profile.location, 'profile.bashrc'))
+ for profile in profiles_complex)
+
if local_config:
#package.properties
propdict = grabdict_package(os.path.join(
@@ -1596,11 +1601,9 @@ class config(object):
bashrc_files = []
- for profile in self._locations_manager.profiles_complex:
- profile_bashrc = os.path.join(profile.location,
- 'profile.bashrc')
- if os.path.exists(profile_bashrc):
- bashrc_files.append(profile_bashrc)
+ for profile, profile_bashrc in zip(self._locations_manager.profiles_complex, self._profile_bashrc):
+ if profile_bashrc:
+ bashrc_files.append(os.path.join(profile.location, 'profile.bashrc'))
if profile in self._pbashrcdict:
cpdict = self._pbashrcdict[profile].get(cp)
if cpdict: