-
Enhancement
-
Resolution: Won't Do
-
Major
-
None
-
None
FRAG4 marshals a long message (that has no array) into smaller fragments, e.g. when frag_size==200, a 500 byte message is marshalled into 3 FragmentedMessages of sizes 200, 200 and 100.
The first FragmentedMessage marshals the entire original message, but only writes the first 200 bytes to the output stream.
The second FragmentedMessage also marshals the entire original message, and writes the second 200 bytes.
The third message writes only the last 100 bytes.
This means that the original message is marshalled 3 times.
It might be faster to create an object that wraps the original message and a byte array, which represents the marshalled object. When marshalled for the first time, the byte array is created. The second and third time, no marshalling is performed, but instead, the FragmentedMessages access the byte array directly (at the given offsets/lengths).