mirror of
https://github.com/apple/swift-http-types
synced 2026-11-30 05:18:47 +00:00
Reserve capacity before appending elements during initialization through dictionary literal
This commit is contained in:
1 parent
12358d55a3
commit
dfefea8004
1 file changed
+1
@@ -280,6 +280,7 @@ public struct HTTPFields: Sendable, Hashable {
|
||||
|
||||
extension HTTPFields: ExpressibleByDictionaryLiteral {
|
||||
public init(dictionaryLiteral elements: (HTTPField.Name, String)...) {
|
||||
self.reserveCapacity(elements.count)
|
||||
for (name, value) in elements {
|
||||
precondition(!name.isPseudo, "Pseudo header field \"\(name)\" disallowed")
|
||||
self._storage.append(field: HTTPField(name: name, value: value))
|
||||
|
||||
Reference in new issue
Block a user