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:
parent
aa95e9e986
commit
0fcb6c26c1
@ -120,6 +120,7 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
#if defined(QT_LOCALSOCKET_TCP)
|
#if defined(QT_LOCALSOCKET_TCP)
|
||||||
|
qint64 skip(qint64 maxSize) override;
|
||||||
QLocalUnixSocket* tcpSocket;
|
QLocalUnixSocket* tcpSocket;
|
||||||
bool ownsTcpSocket;
|
bool ownsTcpSocket;
|
||||||
void setSocket(QLocalUnixSocket*);
|
void setSocket(QLocalUnixSocket*);
|
||||||
@ -139,6 +140,7 @@ public:
|
|||||||
QWindowsPipeReader *pipeReader;
|
QWindowsPipeReader *pipeReader;
|
||||||
QLocalSocket::LocalSocketError error;
|
QLocalSocket::LocalSocketError error;
|
||||||
#else
|
#else
|
||||||
|
qint64 skip(qint64 maxSize) override;
|
||||||
QLocalUnixSocket unixSocket;
|
QLocalUnixSocket unixSocket;
|
||||||
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
|
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
|
||||||
void errorOccurred(QLocalSocket::LocalSocketError, const QString &function);
|
void errorOccurred(QLocalSocket::LocalSocketError, const QString &function);
|
||||||
|
@ -83,6 +83,11 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket)
|
|||||||
tcpSocket->setParent(q);
|
tcpSocket->setParent(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 QLocalSocketPrivate::skip(qint64 maxSize)
|
||||||
|
{
|
||||||
|
return tcpSocket->skip(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
|
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
|
||||||
{
|
{
|
||||||
Q_Q(QLocalSocket);
|
Q_Q(QLocalSocket);
|
||||||
|
@ -88,6 +88,11 @@ void QLocalSocketPrivate::init()
|
|||||||
unixSocket.setParent(q);
|
unixSocket.setParent(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 QLocalSocketPrivate::skip(qint64 maxSize)
|
||||||
|
{
|
||||||
|
return unixSocket.skip(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
|
void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)
|
||||||
{
|
{
|
||||||
Q_Q(QLocalSocket);
|
Q_Q(QLocalSocket);
|
||||||
|
Loading…
Reference in New Issue
Block a user