mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-27 05:04:23 +00:00
Reserve capacity when decoding HPACK headers (#118)
Motivation: I was seeing frequent reallocations of the headers array as it resized during decoding. Modifications: Reserve capacity for at least 16 HPACK headers during decoding. Result: Fewer reallocations at the cost of allocating more than we might need.
This commit is contained in:
1 parent
6a97259a5d
commit
d66cd24206
1 file changed
+1
@@ -89,6 +89,7 @@ public struct HPACKDecoder {
|
||||
// take a local copy to mutate
|
||||
var bufCopy = buffer
|
||||
var headers: [HPACKHeader] = []
|
||||
headers.reserveCapacity(16)
|
||||
|
||||
while bufCopy.readableBytes > 0 {
|
||||
switch try self.decodeHeader(from: &bufCopy) {
|
||||
|
||||
Reference in new issue
Block a user