QAbstractSocket: optimize skipping

Avoid an unnecessary call to the slow base implementation on
buffered TCP socket.

Change-Id: Icc823b416b267aa8e0c1106b20872df9ef0e22d7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Alex Trotsenko 2017-09-12 19:51:45 +03:00
parent 2734a6f24f
commit 41ffe37a5f
2 changed files with 18 additions and 0 deletions

View File

@ -1371,6 +1371,21 @@ void QAbstractSocketPrivate::fetchConnectionParameters()
#endif
}
/*! \internal
*/
qint64 QAbstractSocketPrivate::skip(qint64 maxSize)
{
// if we're not connected, return -1 indicating EOF
if (!socketEngine || !socketEngine->isValid() || state != QAbstractSocket::ConnectedState)
return -1;
// Caller, QIODevice::skip(), has ensured buffer is empty. So, wait
// for more data in buffered mode.
if (isBuffered)
return 0;
return QIODevicePrivate::skip(maxSize);
}
void QAbstractSocketPrivate::pauseSocketNotifiers(QAbstractSocket *socket)
{

View File

@ -71,6 +71,9 @@ public:
QAbstractSocketPrivate();
virtual ~QAbstractSocketPrivate();
// from QIODevicePrivate
qint64 skip(qint64 maxSize) override;
// from QAbstractSocketEngineReceiver
inline void readNotification() override { canReadNotification(); }
inline void writeNotification() override { canWriteNotification(); }