Avoid creating temporary arrays
Motivation:
When we only want the first byte, rather than create temporary intermediate arrays we can just ask NIO to give us the first byte. This avoids unnecessary allocations.
Modifications:
- Replace
readBytes(length: 1).first
withreadInteger(as: UInt8.self)
Results:
11% performance improvement in load testing due to reduced allocator pressure on the hot path.