mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
compiler.types: TVar.find: improve path compression.
After this change, the compiler's complexity is nearly linear even when very large arrays are used.
This commit is contained in:
parent
bf1a583fda
commit
6122fd70ca
@ -71,7 +71,13 @@ class TVar(Type):
|
||||
root = root.parent
|
||||
|
||||
# path compression
|
||||
self.parent = root
|
||||
iter = self
|
||||
while isinstance(iter, TVar):
|
||||
if iter is iter.parent:
|
||||
break
|
||||
else:
|
||||
iter, iter.parent = iter.parent, root
|
||||
|
||||
return root
|
||||
|
||||
def unify(self, other):
|
||||
|
Loading…
Reference in New Issue
Block a user