summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-16 20:38:03 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-16 20:38:03 +0000
commit8fa22d41766a0c6b8198e6d3642c6f969e46da9f (patch)
tree6179639c9efc081375f777a4323e43db13fe00b1 /pym
parent799357a99736027ad85c0978e29b55338c6c5102 (diff)
downloadportage-8fa22d41766a0c6b8198e6d3642c6f969e46da9f.tar.gz
portage-8fa22d41766a0c6b8198e6d3642c6f969e46da9f.tar.bz2
portage-8fa22d41766a0c6b8198e6d3642c6f969e46da9f.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%. M pym/portage/dbapi/vartree.py svn path=/main/trunk/; revision=8151
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 67e10b4e3..38d323849 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -872,6 +872,8 @@ class dblink(object):
self._installed_instance = None
self.contentscache = None
self._contents_inodes = None
+ import re
+ self._normalize_needed = re.compile(r'//|^[^/]|.+/$')
def lockdb(self):
if self._lock_vdb:
@@ -944,6 +946,10 @@ class dblink(object):
mylines = myc.readlines()
myc.close()
null_byte = "\0"
+ normalize_needed = self._normalize_needed
+ myroot = self.myroot
+ if myroot == os.path.sep:
+ myroot = None
pos = 0
for line in mylines:
pos += 1
@@ -957,8 +963,12 @@ class dblink(object):
# 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]]