about summary refs log tree commit diff stats
path: root/miasm2/core/graph.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-04-28 15:24:08 +0200
committerAjax <commial@gmail.com>2015-04-28 15:28:21 +0200
commit6a693f9b2f8534486ad989b6f870b27a68445821 (patch)
treea98190e5981fb3a233b12124c83611ccd9bd58bb /miasm2/core/graph.py
parentd6fef49f84a4c8ce286959097f5e028167c58549 (diff)
downloadmiasm-6a693f9b2f8534486ad989b6f870b27a68445821.tar.gz
miasm-6a693f9b2f8534486ad989b6f870b27a68445821.zip
DepGraph: Speed up 'add_uniq_edge' in the mean case
Diffstat (limited to 'miasm2/core/graph.py')
-rw-r--r--miasm2/core/graph.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index f7a9e8f4..3d1cb7c8 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -52,11 +52,11 @@ class DiGraph(object):
         self._nodes_succ[a].append(b)
         self._nodes_pred[b].append(a)
 
-    def add_uniq_edge(self, a, b):
-        if (a, b) in self._edges:
-            return
-        else:
-            self.add_edge(a, b)
+    def add_uniq_edge(self, src, dst):
+        """Add an edge from @src to @dst if it doesn't already exist"""
+        if (src not in self._nodes_succ or
+            dst not in self._nodes_succ[src]):
+            self.add_edge(src, dst)
 
     def del_edge(self, a, b):
         self._edges.remove((a, b))