Consider writing directly to the backing array in WriteBuffer
As an optimization, we could go into the fallback loop branch if
remaining() < numBytes, then in the short branches we can write directly into the buffer rather than repetitively callingwriteByte, which requires some redundant logic. See e.g.writeUInt64vswriteUInt64Slow.
Originally posted by @tgregg in https://github.com/amazon-ion/ion-java/pull/609#discussion_r1362648083
As an optimization, we could have fast/slow variants of this too, where we do the current technique when
remaining() < numBytes, and otherwise we just write directly into the underlying array.
Originally posted by @tgregg in https://github.com/amazon-ion/ion-java/pull/610#discussion_r1362698735
This might be a good candidate for a method in WriteBuffer. I have a feeling it will ultimately benefit from an optimization that writes directly into the WriteBuffer's array if enough space is available.
Originally posted by @tgregg in https://github.com/amazon-ion/ion-java/pull/612#discussion_r1362739224