mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Motivation: Generics and closures across modules can be problematic as the cause allocations. ByteBuffer is one of NIO's core data types and therefore should be well optimised. Generic/closure taking methods so far were a bit of a problem. And with [SE-0193](https://github.com/apple/swift-evolution/blob/master/proposals/0193-cross-module-inlining-and-specialization.md) accepted, there's not much reason to use those features even though they are (at the moment) @_. For the 1000 requests over 1 connection allocation benchmark we go from "total_allocations": 325378 to "total_allocations": 321366 so we lose 4 allocations per HTTP request/response pair, not super impressive but not nothing either. Modifications: Make generic/closure taking methods on ByteBuffer `@_inlineable` Result: Fewer allocations