QLocalSocket: forward skipping to the inner socket

As QLocalSocket keeps incoming data in the inner socket object, we
can implement the outer's skip() by simply calling the inner's. This
avoids the slow read()-based code path provided by the base class.

Change-Id: I66547601ebad1b4acf168475bebd81fbeef969f8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Alex Trotsenko 2017-09-02 20:04:38 +03:00
parent aa95e9e986
commit 0fcb6c26c1
3 changed files with 12 additions and 0 deletions

View File

@ -120,6 +120,7 @@ public:
void init();
#if defined(QT_LOCALSOCKET_TCP)
qint64 skip(qint64 maxSize) override;
QLocalUnixSocket* tcpSocket;
bool ownsTcpSocket;
void setSocket(QLocalUnixSocket*);
@ -139,6 +140,7 @@ public:
QWindowsPipeReader *pipeReader;
QLocalSocket::LocalSocketError error;
#else
qint64 skip(qint64 maxSize) override;
QLocalUnixSocket unixSocket;
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
void errorOccurred(QLocalSocket::LocalSocketError, const QString &function);

View File

@ -83,6 +83,11 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket)
tcpSocket->setParent(q);
}
qint64 QLocalSocketPrivate::skip(qint64 maxSize)
{
return tcpSocket->skip(maxSize);
}
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
{
Q_Q(QLocalSocket);

View File

@ -88,6 +88,11 @@ void QLocalSocketPrivate::init()
unixSocket.setParent(q);
}
qint64 QLocalSocketPrivate::skip(qint64 maxSize)
{
return unixSocket.skip(maxSize);
}
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
{
Q_Q(QLocalSocket);