I wish to know if there could be any significant difference in terms of mem efficiency between marshaling a struct and marshaling a marshaled struct.
Example: Assume we have a struct B with some fields.
message B{...}
The common representation:
message A {
B b = 1;
}
Another way:
message A {
bytes b = 1;
}
Where b is a marshaled B struct.
Generally, is it a good practice? any efficiency implications?
Thanks, Elad
At the payload level, they are identical - however, in terms of how implementations treat them, there may be differences. The most obvious difference is that you can't use a
bytes
until you further deserialize it; this has pros and cons:So: yes, it will have different characteristics. Whether they are advantageous (or the opposite) depends on whether you also need to do the extra deserialization step on the
bytes
payload