QHttpHeaders: Self-Encapsulate Field d->headers
Use QHttpHeaders::reserve() and QHttpHeaders::isEmpty() instead of going directly to d->headers. Will help in enabling a nullptr d. Change-Id: Id530f8922b17058ec47530523ed43e08927c3ce3 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit f5056a0b53bcc3f095efb5664201e4a0daea9c1e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
268d7b202a
commit
4179204bd7
@ -485,7 +485,7 @@ QHttpHeaders::QHttpHeaders() : d(new QHttpHeadersPrivate)
|
|||||||
QHttpHeaders QHttpHeaders::fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers)
|
QHttpHeaders QHttpHeaders::fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers)
|
||||||
{
|
{
|
||||||
QHttpHeaders h;
|
QHttpHeaders h;
|
||||||
h.d->headers.reserve(headers.size());
|
h.reserve(headers.size());
|
||||||
for (const auto &header : headers)
|
for (const auto &header : headers)
|
||||||
h.append(header.first, header.second);
|
h.append(header.first, header.second);
|
||||||
return h;
|
return h;
|
||||||
@ -500,7 +500,7 @@ QHttpHeaders QHttpHeaders::fromListOfPairs(const QList<std::pair<QByteArray, QBy
|
|||||||
QHttpHeaders QHttpHeaders::fromMultiMap(const QMultiMap<QByteArray, QByteArray> &headers)
|
QHttpHeaders QHttpHeaders::fromMultiMap(const QMultiMap<QByteArray, QByteArray> &headers)
|
||||||
{
|
{
|
||||||
QHttpHeaders h;
|
QHttpHeaders h;
|
||||||
h.d->headers.reserve(headers.size());
|
h.reserve(headers.size());
|
||||||
for (const auto &[name,value] : headers.asKeyValueRange())
|
for (const auto &[name,value] : headers.asKeyValueRange())
|
||||||
h.append(name, value);
|
h.append(name, value);
|
||||||
return h;
|
return h;
|
||||||
@ -515,7 +515,7 @@ QHttpHeaders QHttpHeaders::fromMultiMap(const QMultiMap<QByteArray, QByteArray>
|
|||||||
QHttpHeaders QHttpHeaders::fromMultiHash(const QMultiHash<QByteArray, QByteArray> &headers)
|
QHttpHeaders QHttpHeaders::fromMultiHash(const QMultiHash<QByteArray, QByteArray> &headers)
|
||||||
{
|
{
|
||||||
QHttpHeaders h;
|
QHttpHeaders h;
|
||||||
h.d->headers.reserve(headers.size());
|
h.reserve(headers.size());
|
||||||
for (const auto &[name,value] : headers.asKeyValueRange())
|
for (const auto &[name,value] : headers.asKeyValueRange())
|
||||||
h.append(name, value);
|
h.append(name, value);
|
||||||
return h;
|
return h;
|
||||||
@ -1097,7 +1097,7 @@ QMultiHash<QByteArray, QByteArray> QHttpHeaders::toMultiHash() const
|
|||||||
*/
|
*/
|
||||||
void QHttpHeaders::clear()
|
void QHttpHeaders::clear()
|
||||||
{
|
{
|
||||||
if (d->headers.isEmpty())
|
if (isEmpty())
|
||||||
return;
|
return;
|
||||||
d.detach();
|
d.detach();
|
||||||
d->headers.clear();
|
d->headers.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user