Add QHttpHeaders::reserve()

Found in API-review

Pick-to: 6.7
Change-Id: Ia41eb91e9e62a252b76c20c67c1c599c0f6a633d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
bb10
Juha Vuolle 2024-01-10 15:13:20 +02:00 committed by Marc Mutz
parent d351a97e85
commit b5665f6fab
2 changed files with 13 additions and 0 deletions

View File

@ -1062,6 +1062,18 @@ qsizetype QHttpHeaders::size() const noexcept
return d->headers.size();
}
/*!
Attempts to allocate memory for at least \a size header entries.
If you know in advance how how many header entries there will
be, you may call this function to prevent reallocations
and memory fragmentation.
*/
void QHttpHeaders::reserve(qsizetype size)
{
d->headers.reserve(size);
}
/*!
Compares this instance with \a other and returns \c true if they
are considered equal in accordance with the provided \a options.

View File

@ -245,6 +245,7 @@ public:
Q_NETWORK_EXPORT QByteArray combinedValue(WellKnownHeader name) const;
Q_NETWORK_EXPORT qsizetype size() const noexcept;
Q_NETWORK_EXPORT void reserve(qsizetype size);
bool isEmpty() const noexcept { return size() == 0; }
Q_NETWORK_EXPORT bool equals(const QHttpHeaders &other,