mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: It's not always possible to initialize `HTTPHeaders` with all the headers one needs to set. In such case, the underlying array will be expanded as and when needed upon headers being appended. `Array` provides the means to reserve capacity to optimize such use case. This PR exposes this functionality in `HTTPHeaders`. Modifications: Expose method `reserveCapacity(_ minimumCapacity: Int)` and computed variable `capacity: Int` in `HTTPHeaders` and added some tests. Result: Developers will be able to control the capacity of the underlying headers array as such: ``` var headers = HTTPHeaders() headers.reserveCapacity(5) ``` Co-authored-by: Ludovic Dewailly <ldewailly@apple.com>