diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-11 13:10:04 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-11 13:52:54 (GMT) |
commit | e2a94baeed03edbaeea9b4658f2a820520e1363f (patch) | |
tree | 6b6c58f54728b62e9f8b3774837c09cfacc56bfd /src | |
parent | 7bd7dabe915df8833601a48de3fee6ad7fac82e9 (diff) | |
download | Qt-e2a94baeed03edbaeea9b4658f2a820520e1363f.zip Qt-e2a94baeed03edbaeea9b4658f2a820520e1363f.tar.gz Qt-e2a94baeed03edbaeea9b4658f2a820520e1363f.tar.bz2 |
QNAM HTTP: Optimize eatWhitespace()
Avoid calling socket->bytesAvailable().
Reviewed-by: Thiago
Diffstat (limited to 'src')
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index b612d26..53c2596 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -625,10 +625,17 @@ void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests() void QHttpNetworkConnectionChannel::eatWhitespace() { char c; - while (socket->bytesAvailable()) { - if (socket->peek(&c, 1) != 1) + do { + qint64 ret = socket->peek(&c, 1); + + // nothing read, fine. + if (ret == 0) return; + // EOF from socket? + if (ret == -1) + return; // FIXME, we need to stop processing. however the next stuff done will also do that. + // read all whitespace and line endings if (c == 11 || c == '\n' || c == '\r' || c == ' ' || c == 31) { socket->read(&c, 1); @@ -636,7 +643,7 @@ void QHttpNetworkConnectionChannel::eatWhitespace() } else { break; } - } + } while(true); } void QHttpNetworkConnectionChannel::handleStatus() |