Optimize field set for oneof case#385
Conversation
yanivshaked
left a comment
There was a problem hiding this comment.
Updated files according to test results
|
The problem is we represent We should have a separate value class for Message values are like product types (tuples, records, structs) and they're represented as Enum values are just integers with a mapping from the integers to names, and represented as Oneofs are sums (e.g. enhanced enums in Dart), and we don't have a way to represent sums efficiently currently. Instead we try to use |
I guess generating a class with a single dynamic field would be the easiest solution here without proper language support for sum-types. We could generate the appropriate getters that will do the cast.... |
|
We can't make |
The current implementation initializes an empty List with n fields for a one-of case.
This means, that while one of of the elements in the list will actually be populated, the entire list is initialized taking n times the amount of memory than required.
The suggested change uses a Map instead of a List for the one-of case, reducing amount of memory drastically if one-of has many types to choose from (which is mostly the case).