summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py9
-rw-r--r--pym/portage/__init__.py4
2 files changed, 7 insertions, 6 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 5dbb44795..38f485aae 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -8732,12 +8732,9 @@ class Scheduler(PollLoop):
settings.setcpv(pkg)
pkg.metadata["USE"] = settings["PORTAGE_USE"]
- if self._digraph and \
- self._digraph.contains(pkg):
- for existing_instance in self._digraph.order:
- if existing_instance == pkg:
- pkg = existing_instance
- break
+ if self._digraph is not None:
+ # Reuse existing instance when available.
+ pkg = self._digraph.get(pkg, pkg)
return pkg
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 453096f67..535ea9ed7 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -437,6 +437,9 @@ class digraph(object):
"""Checks if the digraph contains mynode"""
return node in self.nodes
+ def get(self, key, default=None):
+ return self.nodes.get(key, default)
+
def all_nodes(self):
"""Return a list of all nodes in the graph"""
return self.order[:]
@@ -506,6 +509,7 @@ class digraph(object):
allnodes = all_nodes
allzeros = leaf_nodes
hasnode = contains
+ __contains__ = contains
empty = is_empty
copy = clone