From dfefea8004f82e77db6b8c124797130eba1aac26 Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Thu, 1 Feb 2024 00:32:19 +0100 Subject: [PATCH] Reserve capacity before appending elements during initialization through dictionary literal --- Sources/HTTPTypes/HTTPFields.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index ffda625..5d99d56 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -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))