Commit 708875fa authored by Stefan Behnel's avatar Stefan Behnel

keep subtype definition order of fused types also for fused subtypes

avoid antipattern of sum()-ing lists
parent 152e9d58
......@@ -1339,12 +1339,16 @@ class FusedType(CType):
exception_check = 0
def __init__(self, types, name=None):
# Use list rather than set to preserve order.
flattened_types = [t for t in types if not t.is_fused]
subtypes = sum([t.types for t in types if t.is_fused], [])
for type in subtypes:
if type not in flattened_types:
flattened_types.append(type)
# Use list rather than set to preserve order (list should be short).
flattened_types = []
for t in types:
if t.is_fused:
# recursively merge in subtypes
for subtype in t.types:
if subtype not in flattened_types:
flattened_types.append(subtype)
elif t not in flattened_types:
flattened_types.append(t)
self.types = flattened_types
self.name = name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment