diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-17 09:37:13 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-17 10:21:43 (GMT) |
commit | e0a674a5f5735e964d28af3d704757862f74e0b3 (patch) | |
tree | 25fc66b6be4fe103a89241d434a1d89e788cdb7d | |
parent | afedf4a56775d8637146a0c1df17539c3b50a4ae (diff) | |
download | Qt-e0a674a5f5735e964d28af3d704757862f74e0b3.zip Qt-e0a674a5f5735e964d28af3d704757862f74e0b3.tar.gz Qt-e0a674a5f5735e964d28af3d704757862f74e0b3.tar.bz2 |
QNAM HTTP: More micro optimization in QHttpNetworkRequest
Reviewed-by: Zeno Albisser
-rw-r--r-- | src/network/access/qhttpnetworkrequest.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index fd1aa22..9eb2399 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -131,7 +131,11 @@ QByteArray QHttpNetworkRequestPrivate::uri(bool throughProxy) const QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy) { - QByteArray ba = request.d->methodName(); + QList<QPair<QByteArray, QByteArray> > fields = request.header(); + QByteArray ba; + ba.reserve(40 + fields.length()*25); // very rough lower bound estimation + + ba += request.d->methodName(); ba += ' '; ba += request.d->uri(throughProxy); @@ -141,9 +145,9 @@ QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request ba += QByteArray::number(request.minorVersion()); ba += "\r\n"; - QList<QPair<QByteArray, QByteArray> > fields = request.header(); QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin(); - for (; it != fields.constEnd(); ++it) { + QList<QPair<QByteArray, QByteArray> >::const_iterator endIt = fields.constEnd(); + for (; it != endIt; ++it) { ba += it->first; ba += ": "; ba += it->second; |