Add UnsafeByteArrayOutputStream. ByteArrayOutputStreams are used extensively and result in a lot of short lived byte arrays.
This patch contains two optimizations
1/ attempt to provide the final length to ByteArrayOutputStream constructor to avoid constantly resizing the backing array. Default size is 32 which means larger messages may require several array reallocations and almost all will require at least one.
2/ provides the UnsafeByteArrayOutputStream class which eliminates method synchronization. The toByteArray() will return the backing array rather than a copy if the correct length was provided in the constructor.
In the worst case scenario this cuts array allocations from 3 to 2.
In the most common worst case from 3 to 1.
In most best cases where final array size is greater than 128 bytes from > 4 to 1.
1) Added getters and setters to many objects that lacked them.
2) Introduce a parseLite method that is called even in "lazy parse" mode. This calculates the length of the message so children can be skipped when parsing a container object.
3) Full serialization for AddressMessage
4) Added a (huge, standalone) SpeedTest.
5) Add unit tests for the matrix of lazy parsing modes.
A bunch of review comments are added to the TODO list for completion after the patch series is checked in. This is to avoid large numbers of merge conflicts as later parts of the patch-series are committed.
1) Introduce partial support for caching the underlying byte arrays during message deserialization, so re-serialization can be skipped in the case where a message is not modified.
2) Add c'tors that allow a message to be configured to lazily parse on-demand.
Note that the getters/setters that make lazy parsing transparent are coming in future commits.