瀏覽代碼

Performance improvement

Yentl Van Tendeloo 7 年之前
父節點
當前提交
c5e099550d
共有 1 個文件被更改,包括 3 次插入14 次删除
  1. 3 14
      interface/HUTN/hutn_compiler/hutnparser.py

+ 3 - 14
interface/HUTN/hutn_compiler/hutnparser.py

@@ -762,29 +762,18 @@ class Parser(object):
 
         if (not cardrule in self.countcard):
             count = delta
-            self.countcard.update({cardrule: {j: count}})
+            self.countcard[cardrule] = {j: count}
         else:
             if not j in self.countcard[cardrule]:  # # if we already know the count for j, then ignore..
                 d = self.countcard[cardrule]
                 lastcount = 0
-                ## Performance bottleneck
-                #print("J: %s, d: %s" % (j, d))
-                for i in range(0, j):
-                    if i in d:
-                        lastcount = d[i]
-                #print("Result: " + str(lastcount))
-                ## End of performance bottleneck
-                new_lastcount = 0
                 for i in sorted(d.keys()):
                     if i < j:
-                        new_lastcount = d[i]
+                        lastcount = d[i]
                     else:
                         break
-                if lastcount != new_lastcount:
-                    raise Exception()
-                ## End new code
                 count = lastcount + delta
-                d.update({j: count})
+                d[j] = count
             else:
                 count = self.countcard[cardrule][j]