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:
parent
2734a6f24f
commit
41ffe37a5f
@ -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)
|
||||
{
|
||||
|
@ -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(); }
|
||||
|
Loading…
Reference in New Issue
Block a user