Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor decoding, part 1 #264

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented Feb 7, 2024

This is the first PR of a mini series to refactor the decoding code of odxtools. In this PR, we refactor the DecodeState class with the aim of not having to create copies during the decoding process:

  • the attributes cursor_position and origin_position are introduced. The former points to the first undecoded byte whilst the latter points to the byte to which relative positions given by the BYTE-POSITION tag refer to.
  • the parameter_values property is removed. Instead, the parameter values are kept as local variables in the respective decoding functions.
  • length_keys and table_keys attributes are introduced, to keep track of inter-parameter dependencies

note that the "do not create copies" aim is not yet fully reached after this PR, but it will be at the end of this PR series...

Andreas Lauser <[email protected]>, on behalf of MBition GmbH.
Provider Information

the purpose of this is to make the decoding routine a bit more
transparent and slightly more performant:

instead of copying the blob to be decoded, we now keep this constant
and have an `origin_position` attribute besides `cursor_position`. The
`origin_position` is the position within the blob to be decoded to
which relative positions of positionable parameters are ancored
to. This allows objects like structures, to just modify the origin
position of the decode state instead of creating a completely new one.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Katja Köhler <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Katja Köhler <[email protected]>
@andlaus andlaus requested a review from kayoub5 February 7, 2024 09:36
@andlaus
Copy link
Collaborator Author

andlaus commented Feb 8, 2024

thanks for the review @kayoub5 !

@andlaus andlaus merged commit 240718a into mercedes-benz:main Feb 8, 2024
6 checks passed
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