Skip to content

Commit

Permalink
Improve performance of specification parser
Browse files Browse the repository at this point in the history
Ref. #95, #343, #466
  • Loading branch information
treiher committed Oct 19, 2020
1 parent 20bbc46 commit 5aca61b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rflx/specification/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,13 @@ def create_message_structure(components: Sequence[Component], error: RecordFluxE
target_node = Field(name) if name else FINAL
structure.append(Link(source_node, target_node))

if component.first != expr.UNDEFINED:
for l in structure:
if l.target.identifier == component.name:
if (
component.first != expr.UNDEFINED
or component.length != expr.UNDEFINED
or component.condition != expr.TRUE
):
for l in (l for l in structure if l.target.identifier == component.name):
if component.first != expr.UNDEFINED:
if l.first == expr.UNDEFINED:
l.first = component.first
else:
Expand All @@ -352,9 +356,7 @@ def create_message_structure(components: Sequence[Component], error: RecordFluxE
l.first.location,
)

if component.length != expr.UNDEFINED:
for l in structure:
if l.target.identifier == component.name:
if component.length != expr.UNDEFINED:
if l.length == expr.UNDEFINED:
l.length = component.length
else:
Expand All @@ -372,9 +374,7 @@ def create_message_structure(components: Sequence[Component], error: RecordFluxE
l.length.location,
)

if component.condition != expr.TRUE:
for l in structure:
if l.target.identifier == component.name:
if component.condition != expr.TRUE:
l.condition = (
expr.And(component.condition, l.condition, location=l.condition.location)
if l.condition != expr.TRUE
Expand Down

0 comments on commit 5aca61b

Please sign in to comment.