Skip to content
  • Lukasa's avatar
    Avoid creating temporary arrays · f9579373
    Lukasa authored and Nathan Harris's avatar Nathan Harris committed
    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` with `readInteger(as:
      UInt8.self)`
    
    Results:
    
    11% performance improvement in load testing due to reduced allocator
    pressure on the hot path.
    f9579373