diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-09-23 06:35:55 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-09-23 06:35:55 +0000 |
commit | 6d895f047e7d2947aab862de3f6103440f248fc4 (patch) | |
tree | 478b824cf46876b55bd3918e759b70bf7ce5b543 | |
parent | cc9856b20d6d2188b4a54c419efc68f2aa627fa6 (diff) | |
download | portage-6d895f047e7d2947aab862de3f6103440f248fc4.tar.gz portage-6d895f047e7d2947aab862de3f6103440f248fc4.tar.bz2 portage-6d895f047e7d2947aab862de3f6103440f248fc4.zip |
Optimize vardbapi.getpath(). Thanks to Marat Radchenko
<marat@slonopotamus.org> for this patch.
svn path=/main/trunk/; revision=14392
-rw-r--r-- | pym/portage/dbapi/vartree.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 2bbc0f88a..d2160896e 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -50,6 +50,7 @@ from portage.cache.mappings import slot_dict_class import codecs import re, shutil, stat, errno, copy, subprocess import logging +import os as _os import sys import warnings @@ -839,9 +840,13 @@ class vardbapi(dbapi): self._owners = self._owners_db(self) def getpath(self, mykey, filename=None): - rValue = os.path.join(self.root, VDB_PATH, mykey) - if filename != None: - rValue = os.path.join(rValue, filename) + # This is an optimized hotspot, so don't use unicode-wrapped + # os module and don't use os.path.join(). + rValue = self.root + _os.sep + VDB_PATH + _os.sep + mykey + if filename is not None: + # If filename is always relative, we can do just + # rValue += _os.sep + filename + rValue = _os.path.join(rValue, filename) return rValue def cpv_exists(self, mykey): |