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

Efficient enum encodings #303

Merged
merged 6 commits into from
Apr 20, 2024
Merged

Efficient enum encodings #303

merged 6 commits into from
Apr 20, 2024

Conversation

usr3-1415
Copy link
Collaborator

Optimize Generated C Code for Enumerated Types

This PR introduces a new mode in asn1scc that optimizes the generated C code for ASN.1 Enumerated types, especially when there are multiple enumerants in the type (e.g., 50 or more).

When the -eee option is present, asn1scc generates more efficient and less verbose code. Instead of generating switch statements, asn1scc generates sorted arrays containing the possible values. Lookups, such as for validation or index retrieval in uPER encoding, are performed using an optimized binary search.

This results in more efficient code generation for large Enumerated types, improving performance and readability.

To use this mode, pass the minimum number of enumerants in an enumerated type to enable this mode as an argument to the -eee option. For example, -eee 50 will enable this mode for enumerated types with 50 or more enumerants.

@usr3-1415 usr3-1415 merged commit e1f6ca1 into master Apr 20, 2024
5 checks passed
@usr3-1415 usr3-1415 deleted the EfficientEnumEncodings branch April 20, 2024 19:59
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.

1 participant