summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-11-26 13:09:09 -0800
committerZac Medico <zmedico@gentoo.org>2010-11-26 13:09:09 -0800
commit07057dd0c4e0a7ed1f719ec267a64094a241f5e0 (patch)
tree7e6d68f64dcaa535fb2a55d89ffd97f2a33fb64c
parent637206243c364662cd2dc511d7c833e70570a55a (diff)
downloadportage-07057dd0c4e0a7ed1f719ec267a64094a241f5e0.tar.gz
portage-07057dd0c4e0a7ed1f719ec267a64094a241f5e0.tar.bz2
portage-07057dd0c4e0a7ed1f719ec267a64094a241f5e0.zip
portdbapi: eliminate redundant treemap lookups
-rw-r--r--pym/portage/dbapi/porttree.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index b3a219517..2f6b9dd16 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -248,9 +248,7 @@ class portdbapi(dbapi):
it must return a path to the repository
TreeMap = { id:path }
"""
- if repository_id in self.treemap:
- return self.treemap[repository_id]
- return None
+ return self.treemap.get(repository_id)
def getRepositoryName(self, canonical_repo_path):
"""
@@ -300,12 +298,11 @@ class portdbapi(dbapi):
if not mycpv:
return (None, 0)
- if myrepo:
- if myrepo in self.treemap:
- mytree = self.treemap[myrepo]
- else:
+ if myrepo is not None:
+ mytree = self.treemap.get(myrepo)
+ if mytree is None:
return (None, 0)
-
+
mysplit = mycpv.split("/")
psplit = pkgsplit(mysplit[1])
if psplit is None or len(mysplit) != 2:
@@ -434,12 +431,11 @@ class portdbapi(dbapi):
'input: "sys-apps/foo-1.0",["SLOT","DEPEND","HOMEPAGE"]'
'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com"] or raise KeyError if error'
cache_me = False
- if myrepo:
- if myrepo in self.treemap:
- mytree = self.treemap[myrepo]
- else:
+ if myrepo is not None:
+ mytree = self.treemap.get(myrepo)
+ if mytree is None:
raise KeyError(myrepo)
-
+
if not mytree:
cache_me = True
if not mytree and not self._known_keys.intersection(
@@ -626,10 +622,9 @@ class portdbapi(dbapi):
elif useflags is None:
if mysettings:
useflags = mysettings["USE"].split()
- if myrepo:
- if myrepo in self.treemap:
- mytree = self.treemap[myrepo]
- else:
+ if myrepo is not None:
+ mytree = self.treemap.get(myrepo)
+ if mytree is None:
return False
else:
mytree = None