Skip to content

Commit

Permalink
Remove separate init() + reserveCapacity on HTTPFields, as it's much …
Browse files Browse the repository at this point in the history
…slower than expected
  • Loading branch information
Joannis committed May 19, 2024
1 parent affc9e9 commit 90751b1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Sources/Hummingbird/Utils/HTTPFields+Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import HTTPTypes

extension HTTPFields {
init(contentType: String, contentLength: Int) {
self.init()

// Content-Type, Content-Length, Server, Date + 2 extra headers
// This should cover our expected amount of headers
self.reserveCapacity(6)

self[.contentType] = contentType
self[.contentLength] = String(describing: contentLength)
self = [
.contentType: contentType,
.contentLength: String(describing: contentLength)
]
}
}

0 comments on commit 90751b1

Please sign in to comment.