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

Slightly reduced memory footprint of API structs and enums #1732

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krzychu124
Copy link
Member

@krzychu124 krzychu124 commented Mar 16, 2023

  • slightly reduced memory footprint of API structs by applying Auto Struct layout (improves alignment and reduces offsets of unused memory between fields of the struct)
  • changed backing type of enums to byte which in turn should also reduce size of structs a little where used
  • fixed InvalidCastException when casting byte to generic enum in DropDownOption<TEnum>,

Note it's not possible to constraint Enum backing type to byte in DropDownOption so all enums used for dropdown ui must have a byte as backing type otherwise will throw InvalidCastException at runtime.
Whole implementation has a flaw anyways because current implementation of SerializableUIOption is saving value as byte so any enum larger than byte will be saved and restored incorrectly. For now everything works because we don't use such big enums for dropdown values, so it's something to handle in the future or better avoid such use case.

Build ZIP

@krzychu124 krzychu124 added enhancement Improve existing feature performance Make it faster! labels Mar 16, 2023
@krzychu124 krzychu124 self-assigned this Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing feature performance Make it faster!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant