mirror of https://github.com/m-labs/artiq.git
Fix accidentally quadratic code in compiler.ir.Function._add_name.
This commit is contained in:
parent
6d8d0ff3f5
commit
d7f9af4bb5
|
@ -396,6 +396,7 @@ class Function:
|
||||||
def __init__(self, typ, name, arguments):
|
def __init__(self, typ, name, arguments):
|
||||||
self.type, self.name = typ, name
|
self.type, self.name = typ, name
|
||||||
self.names, self.arguments, self.basic_blocks = set(), [], []
|
self.names, self.arguments, self.basic_blocks = set(), [], []
|
||||||
|
self.next_name = 1
|
||||||
self.set_arguments(arguments)
|
self.set_arguments(arguments)
|
||||||
self.is_internal = False
|
self.is_internal = False
|
||||||
|
|
||||||
|
@ -403,13 +404,14 @@ class Function:
|
||||||
self.names.remove(name)
|
self.names.remove(name)
|
||||||
|
|
||||||
def _add_name(self, base_name):
|
def _add_name(self, base_name):
|
||||||
name, counter = base_name, 1
|
|
||||||
while name in self.names or name == "":
|
|
||||||
if base_name == "":
|
if base_name == "":
|
||||||
name = "v.{}".format(str(counter))
|
name = "v.{}".format(self.next_name)
|
||||||
|
self.next_name += 1
|
||||||
|
elif base_name in self.names:
|
||||||
|
name = "{}.{}".format(base_name, self.next_name)
|
||||||
|
self.next_name += 1
|
||||||
else:
|
else:
|
||||||
name = "{}.{}".format(name, counter)
|
name = base_name
|
||||||
counter += 1
|
|
||||||
|
|
||||||
self.names.add(name)
|
self.names.add(name)
|
||||||
return name
|
return name
|
||||||
|
|
Loading…
Reference in New Issue