summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2016-08-18 20:25:12 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2016-08-19 08:16:16 +0000
commit6f0814ab83317e8dcf13d9d94e6aaea5a68915f5 (patch)
treed62812cc6b1a39515c1db9f20d2993fed58bd93b /src
parenta23b71d2d020505a2bc11adbbcfb0516319291c2 (diff)
Micro-optimize QAbstractSocketPrivate::canReadNotification()
Remove unnecessary checks in release build. Refactor the code. Change-Id: Ibee96790cbc8beb000757fc8e152fb4dcae9d506 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/network/socket/qabstractsocket.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 662c8e957e..87ef31fb22 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -693,14 +693,6 @@ bool QAbstractSocketPrivate::canReadNotification()
qDebug("QAbstractSocketPrivate::canReadNotification()");
#endif
- if (!isBuffered) {
- if (hasPendingData) {
- socketEngine->setReadNotificationEnabled(false);
- return true;
- }
- hasPendingData = true;
- }
-
// If buffered, read data from the socket into the read buffer
if (isBuffered) {
const qint64 oldBufferSize = buffer.size();
@@ -730,18 +722,21 @@ bool QAbstractSocketPrivate::canReadNotification()
// to indicate that the data was discarded.
return !q->isReadable();
}
+ } else {
+ if (hasPendingData) {
+ socketEngine->setReadNotificationEnabled(false);
+ return true;
+ }
+ hasPendingData = true;
}
emitReadyRead();
- // If we were closed as a result of the readyRead() signal,
- // return.
- if (state == QAbstractSocket::UnconnectedState || state == QAbstractSocket::ClosingState) {
#if defined (QABSTRACTSOCKET_DEBUG)
+ // If we were closed as a result of the readyRead() signal.
+ if (state == QAbstractSocket::UnconnectedState || state == QAbstractSocket::ClosingState)
qDebug("QAbstractSocketPrivate::canReadNotification() socket is closing - returning");
#endif
- return true;
- }
return true;
}