mirror of
https://github.com/apple/swift-nio
synced 2026-11-27 05:04:22 +00:00
### Motivation: `ByteBuffer.firsIndex` is of suboptimal performance. The default Collection implementations don't go through any "magic underscored" functions like `_customIndexOfEquatableElement`. ### Modifications: Manually implement `firstIndex(where:)`. ### Result: Basically free performance boost. 2x+ boost even for not big buffers of a few hundred bytes. There are some usage of this function in `BufferedReader`. Those will become much faster. Also this function is used in `ByteBufferView.trim(limitingElements:)`. Also makes #3411 stuff faster. See: https://github.com/apple/swift-nio/pull/3411#discussion_r2436260691