summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-17 02:51:48 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-17 02:51:48 +0000
commit29a66a7a677f39a5929b643585b9ba6ee3b05c04 (patch)
tree08749ea5bdc4ae1425f55d1b360954ed3452e6d1 /pym
parente20d7e50dc36beb95e4ea1d25a636e25be348557 (diff)
downloadportage-29a66a7a677f39a5929b643585b9ba6ee3b05c04.tar.gz
portage-29a66a7a677f39a5929b643585b9ba6ee3b05c04.tar.bz2
portage-29a66a7a677f39a5929b643585b9ba6ee3b05c04.zip
In dblink.getcontents(), use a regular expression to detect
when path normalization is required. Also, only join with ${ROOT} when necessary. This allows unnecessary normpath and join calls to be optimized away in the general case, reducing the cpu time for `equery belongs <filename>` by about 50%. (trunk r8150:8152) svn path=/main/branches/2.1.2/; revision=8156
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 7245151b1..3c7a12242 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -7160,6 +7160,10 @@ class dblink:
This class provides an interface to the installed package database
At present this is implemented as a text backend in /var/db/pkg.
"""
+
+ import re
+ self._normalize_needed = re.compile(r'//|^[^/]|.+/$')
+
def __init__(self, cat, pkg, myroot, mysettings, treetype=None,
vartree=None):
"""
@@ -7293,7 +7297,10 @@ class dblink:
mylines=myc.readlines()
myc.close()
null_byte = "\0"
- contents_file = os.path.join(self.dbdir, "CONTENTS")
+ normalize_needed = self._normalize_needed
+ myroot = self.myroot
+ if myroot == os.path.sep:
+ myroot = None
pos = 0
for line in mylines:
pos += 1
@@ -7307,8 +7314,12 @@ class dblink:
# we do this so we can remove from non-root filesystems
# (use the ROOT var to allow maintenance on other partitions)
try:
- mydat[1] = normalize_path(os.path.join(
- self.myroot, mydat[1].lstrip(os.path.sep)))
+ if normalize_needed.match(mydat[1]):
+ mydat[1] = normalize_path(mydat[1])
+ if not mydat[1].startswith(os.path.sep):
+ mydat[1] = os.path.sep + mydat[1]
+ if myroot:
+ mydat[1] = os.path.join(myroot, mydat[1].lstrip(os.path.sep))
if mydat[0]=="obj":
#format: type, mtime, md5sum
pkgfiles[" ".join(mydat[1:-2])]=[mydat[0], mydat[-1], mydat[-2]]