Skip to content

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 (reverted)
  • fixed InvalidCastException when casting byte to generic enum in DropDownOption<TEnum>, (reverted)

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.

Reverted change in enum backing type.

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
@krzychu124 krzychu124 force-pushed the enhancement/api-structs-optimization branch from b087884 to f48f3a5 Compare September 23, 2025 23:44
@krzychu124 krzychu124 added this to the 11.9.2.0 milestone Sep 24, 2025
@krzychu124 krzychu124 marked this pull request as ready for review September 24, 2025 01:21
@krzychu124 krzychu124 changed the title Slightly reduced memory footprint of API structs and enums Slightly reduced memory footprint of API structs Sep 24, 2025
@krzychu124 krzychu124 merged commit b486456 into master Sep 24, 2025
2 checks passed
@krzychu124 krzychu124 mentioned this pull request Sep 24, 2025
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.

2 participants