writeSize method
Writes a non-negative 32-bit integer value
to buffer
using an expanding 1-5 byte encoding that optimizes for small values.
This method is intended for use by subclasses overriding writeValue.
Implementation
void writeSize(WriteBuffer buffer, int value) {
assert(0 <= value && value <= 0xffffffff);
if (value < 254) {
buffer.putUint8(value);
} else if (value <= 0xffff) {
buffer.putUint8(254);
buffer.putUint16(value);
} else {
buffer.putUint8(255);
buffer.putUint32(value);
}
}