소스 검색

Fix the RD(E) cache when one of the outgoing links is not a value

Yentl Van Tendeloo 8 년 전
부모
커밋
191e32f47c
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      state/modelverse_state/main.py

+ 3 - 3
state/modelverse_state/main.py

@@ -215,7 +215,7 @@ class ModelverseState(object):
             first = self.cache[node][value]
             # Got hit, so validate
             if (self.edges[first][0] == node) and \
-                (value in [self.values[self.edges[i][1]] for i in self.outgoing[first]]):
+                (value in [self.values[self.edges[i][1]] for i in self.outgoing[first] if self.edges[i][1] in self.values]):
                 return self.edges[first][1]
             # Hit but invalid now
             del self.cache[node][value]
@@ -229,12 +229,12 @@ class ModelverseState(object):
             return None
 
         result = []
+        #NOTE cannot just use the cache here, as some keys in the cache might not actually exist; we would have to check all of them anyway
         if node in self.outgoing:
             for e1 in self.outgoing[node]:
                 if e1 in self.outgoing:
                     for e2 in self.outgoing[e1]:
                         result.append(self.edges[e2][1])
-        #NOTE cannot just use the cache here, as some keys in the cache might not actually exist; we would have to check all of them anyway
         return result
 
     def read_dict_edge(self, node, value):
@@ -242,7 +242,7 @@ class ModelverseState(object):
             first = self.cache[node][value]
             # Got hit, so validate
             if (self.edges[first][0] == node) and \
-                (value in [self.values[self.edges[i][1]] for i in self.outgoing[first]]):
+                (value in [self.values[self.edges[i][1]] for i in self.outgoing[first] if self.edges[i][1] in self.values]):
                 return first
             # Hit but invalid now
             del self.cache[node][value]