diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2009-09-22 10:35:29 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-11 10:38:33 (GMT) |
commit | a7dfc472b06966393a9d9c394d91ed8974b9cfb6 (patch) | |
tree | 3d134d7b169574b64b0d8dd28003254be45fc3fc /src/network/access/qhttpnetworkheader.cpp | |
parent | afffa7cd099379d78ada4c96c2284e87f77d7bb2 (diff) | |
download | Qt-a7dfc472b06966393a9d9c394d91ed8974b9cfb6.zip Qt-a7dfc472b06966393a9d9c394d91ed8974b9cfb6.tar.gz Qt-a7dfc472b06966393a9d9c394d91ed8974b9cfb6.tar.bz2 |
QNAM: Remove some more occurences of toLower on the hot path
toLower will force a memory allocation, and memory allocations
are certainly adding a delay. Use qstricmp were this is easily
possible. This change makes headerValues et all drop out of
the profile.
QChar::toLower will now be called more often, specially for
loops that do linear searching. In the profile with real web
content this is faster than using QByteArry::toLower in the
inner loop and the forced memory allocations.
Reviewed-By: Markus Goetz
Diffstat (limited to 'src/network/access/qhttpnetworkheader.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkheader.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp index 68ed3e5..e9866ca 100644 --- a/src/network/access/qhttpnetworkheader.cpp +++ b/src/network/access/qhttpnetworkheader.cpp @@ -92,11 +92,10 @@ QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const { QList<QByteArray> result; - QByteArray lowerName = name.toLower(); QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(), end = fields.constEnd(); for ( ; it != end; ++it) - if (lowerName == it->first.toLower()) + if (qstricmp(name.constData(), it->first) == 0) result += it->second; return result; @@ -104,10 +103,9 @@ QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data) { - QByteArray lowerName = name.toLower(); QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(); while (it != fields.end()) { - if (lowerName == it->first.toLower()) + if (qstricmp(name.constData(), it->first) == 0) it = fields.erase(it); else ++it; |