mirror of https://github.com/m-labs/artiq.git
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
|
root = root.parent
|
||||||
|
|
||||||
# path compression
|
# 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
|
return root
|
||||||
|
|
||||||
def unify(self, other):
|
def unify(self, other):
|
||||||
|
|
Loading…
Reference in New Issue