QNetworkHeadersPrivate: use erase and std::remove_if with QList
... instead of using erase in a loop, with quadratic complexity. Change-Id: I91053ddb58639615e8864e5be20861e7cceb815e Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
49388f3dfd
commit
f416561702
@ -51,6 +51,8 @@
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
@ -991,13 +993,12 @@ void QNetworkHeadersPrivate::setCookedHeader(QNetworkRequest::KnownHeaders heade
|
||||
|
||||
void QNetworkHeadersPrivate::setRawHeaderInternal(const QByteArray &key, const QByteArray &value)
|
||||
{
|
||||
RawHeadersList::Iterator it = rawHeaders.begin();
|
||||
while (it != rawHeaders.end()) {
|
||||
if (qstricmp(it->first.constData(), key.constData()) == 0)
|
||||
it = rawHeaders.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
auto firstEqualsKey = [&key](const RawHeaderPair &header) {
|
||||
return qstricmp(header.first.constData(), key.constData()) == 0;
|
||||
};
|
||||
rawHeaders.erase(std::remove_if(rawHeaders.begin(), rawHeaders.end(),
|
||||
firstEqualsKey),
|
||||
rawHeaders.end());
|
||||
|
||||
if (value.isNull())
|
||||
return; // only wanted to erase key
|
||||
|
Loading…
Reference in New Issue
Block a user