Skip to content

Conversation

@olabusayoT
Copy link
Contributor

  • Add support for including terminator MTA and length in endingAlignmentApprox calculations.
  • Introduce terminatorMTAApprox and terminatorLengthApprox for reusable terminator alignment logic.
  • Add new test cases (test_sep_alignment_5, test_sep_alignment_6) to validate terminator alignment in sequences.
  • Update comments

DAFFODIL-3057

- Add support for including terminator MTA and length in `endingAlignmentApprox` calculations.
- Introduce `terminatorMTAApprox` and `terminatorLengthApprox` for reusable terminator alignment logic.
- Add new test cases (`test_sep_alignment_5`, `test_sep_alignment_6`) to validate terminator alignment in sequences.
- Update comments

DAFFODIL-3057
Copy link
Member

@stevedlawrence stevedlawrence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Looks good, just minor cleanup/corrections

Comment on lines 241 to 242
LengthMultipleOf(t.knownEncodingAlignmentInBits)
case _ => LengthMultipleOf(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these want to be AlignmentMultipleOf since they represent an alignment and not a length. I imagine the math ends up the same. Though maybe the default case then becomes AlignmentMultipleOf(1)?

}

private lazy val terminatorMTAApprox =
this match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this match case be simplified to an if-statement?

case t if t.hasTerminator =>
getEncodingLengthApprox(t)
case _ => LengthMultipleOf(0)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, can this be simplified to an if-statement?

+ trailingSkipApprox
)
res
} else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding the same three fields to a bunch of places in the various conditions can we do something like

val contentEndAlignment = ... //existing logic
val res =
  contentEndAlignment
    + terminatorMTAAPprox
    + terminatorLengthApprox
    + trailingSkipApprox

I'm not sure if contentEndAlignment is the right name, but something along those lines?

- MTA are alignments not lengths
- simplify pattern matching to if statement
- refactor duplicate addition of terminator + trailing skip

DAFFODIL-2295
@olabusayoT
Copy link
Contributor Author

Subsumed by #1604

@olabusayoT olabusayoT closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants