summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2024-01-10 15:13:20 +0200
committerMarc Mutz <marc.mutz@qt.io>2024-01-11 05:03:48 +0000
commitb5665f6fab40232a81a056523608c295c8167bc6 (patch)
tree76980ac91fb750c6daa4e26395e9456a700d0f6a /src/network/access
parentd351a97e85e5ed8acd7ad1357ef76dc2e0ad639f (diff)
Add QHttpHeaders::reserve()
Found in API-review Pick-to: 6.7 Change-Id: Ia41eb91e9e62a252b76c20c67c1c599c0f6a633d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpheaders.cpp12
-rw-r--r--src/network/access/qhttpheaders.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/network/access/qhttpheaders.cpp b/src/network/access/qhttpheaders.cpp
index c0e2b336f1..4201b2b4d8 100644
--- a/src/network/access/qhttpheaders.cpp
+++ b/src/network/access/qhttpheaders.cpp
@@ -1063,6 +1063,18 @@ qsizetype QHttpHeaders::size() const noexcept
}
/*!
+ 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.
diff --git a/src/network/access/qhttpheaders.h b/src/network/access/qhttpheaders.h
index 7dfcdcef19..5a0a059559 100644
--- a/src/network/access/qhttpheaders.h
+++ b/src/network/access/qhttpheaders.h
@@ -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,