forked from qt-creator/qt-creator
LSP: Do not copy a message before sending it out
Change-Id: I58cc1f50b504bf21ea4ee9f99edba2ae8dc1ca1c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -172,11 +172,6 @@ bool BaseMessage::isValid() const
|
|||||||
return contentLength >= 0;
|
return contentLength >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray BaseMessage::toData() const
|
|
||||||
{
|
|
||||||
return header() + content;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray BaseMessage::header() const
|
QByteArray BaseMessage::header() const
|
||||||
{
|
{
|
||||||
QByteArray header;
|
QByteArray header;
|
||||||
|
@@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
bool isComplete() const;
|
bool isComplete() const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
QByteArray toData() const;
|
QByteArray header() const;
|
||||||
|
|
||||||
QByteArray mimeType;
|
QByteArray mimeType;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
@@ -64,7 +64,6 @@ public:
|
|||||||
QTextCodec *codec = defaultCodec();
|
QTextCodec *codec = defaultCodec();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray header() const;
|
|
||||||
QByteArray lengthHeader() const;
|
QByteArray lengthHeader() const;
|
||||||
QByteArray typeHeader() const;
|
QByteArray typeHeader() const;
|
||||||
};
|
};
|
||||||
|
@@ -48,7 +48,8 @@ BaseClientInterface::~BaseClientInterface()
|
|||||||
|
|
||||||
void BaseClientInterface::sendMessage(const BaseMessage &message)
|
void BaseClientInterface::sendMessage(const BaseMessage &message)
|
||||||
{
|
{
|
||||||
sendData(message.toData());
|
sendData(message.header());
|
||||||
|
sendData(message.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseClientInterface::resetBuffer()
|
void BaseClientInterface::resetBuffer()
|
||||||
|
@@ -358,7 +358,7 @@ void tst_LanguageServerProtocol::baseMessageToData()
|
|||||||
QFETCH(BaseMessage, message);
|
QFETCH(BaseMessage, message);
|
||||||
QFETCH(QByteArray, data);
|
QFETCH(QByteArray, data);
|
||||||
|
|
||||||
QCOMPARE(message.toData(), data);
|
QCOMPARE(message.header() + message.content, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_LanguageServerProtocol::fromJsonValue()
|
void tst_LanguageServerProtocol::fromJsonValue()
|
||||||
|
Reference in New Issue
Block a user