Browse Source

Performance improvement

Yentl Van Tendeloo 7 years ago
parent
commit
c5e099550d
1 changed files with 3 additions and 14 deletions
  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]