public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-portage-dev] [PATCH] config: cache profile.bashrc stat results (bug 649806)
@ 2018-07-15  5:05 99% Zac Medico
  0 siblings, 0 replies; 1+ results
From: Zac Medico @ 2018-07-15  5:05 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

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
---
 pym/portage/package/ebuild/config.py | 13 ++++++++-----
 1 file 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:
-- 
2.13.6



^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2018-07-15  5:05 99% [gentoo-portage-dev] [PATCH] config: cache profile.bashrc stat results (bug 649806) Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox