Skip to content

Commit

Permalink
refactor: union and issuperset
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarice committed Jan 24, 2025
1 parent e49877b commit ad87012
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions xdsl/irdl/declarative_assembly_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,13 @@ def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> No
)
op_def = op.get_irdl_definition()
dictionary = op.attributes | op.properties
default_names = set(
reserved_or_default = self.reserved_attr_names.union(
name
for name, d in (op_def.properties | op_def.attributes).items()
if d.default_value is not None
and dictionary.get(name) == d.default_value
)
reserved_or_default = self.reserved_attr_names | default_names
if not (set(dictionary.keys())) - reserved_or_default:
if reserved_or_default.issuperset(dictionary.keys()):
return
printer.print_op_attributes(
dictionary,
Expand All @@ -461,14 +460,13 @@ def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> No
)
else:
op_def = op.get_irdl_definition()
default_names = set(
reserved_or_default = self.reserved_attr_names.union(
name
for name, d in op_def.attributes.items()
if d.default_value is not None
and op.attributes.get(name) == d.default_value
)
reserved_or_default = self.reserved_attr_names | default_names
if not set(op.attributes.keys()) - reserved_or_default:
if reserved_or_default.issuperset(op.attributes.keys()):
return
printer.print_op_attributes(
op.attributes,
Expand Down

0 comments on commit ad87012

Please sign in to comment.