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:
Christian Kandeler
2022-05-09 13:16:58 +02:00
parent fa577eb049
commit db1f2c8dd9
4 changed files with 4 additions and 9 deletions

View File

@@ -172,11 +172,6 @@ bool BaseMessage::isValid() const
return contentLength >= 0;
}
QByteArray BaseMessage::toData() const
{
return header() + content;
}
QByteArray BaseMessage::header() const
{
QByteArray header;

View File

@@ -56,7 +56,7 @@ public:
bool isComplete() const;
bool isValid() const;
QByteArray toData() const;
QByteArray header() const;
QByteArray mimeType;
QByteArray content;
@@ -64,7 +64,6 @@ public:
QTextCodec *codec = defaultCodec();
private:
QByteArray header() const;
QByteArray lengthHeader() const;
QByteArray typeHeader() const;
};

View File

@@ -48,7 +48,8 @@ BaseClientInterface::~BaseClientInterface()
void BaseClientInterface::sendMessage(const BaseMessage &message)
{
sendData(message.toData());
sendData(message.header());
sendData(message.content);
}
void BaseClientInterface::resetBuffer()

View File

@@ -358,7 +358,7 @@ void tst_LanguageServerProtocol::baseMessageToData()
QFETCH(BaseMessage, message);
QFETCH(QByteArray, data);
QCOMPARE(message.toData(), data);
QCOMPARE(message.header() + message.content, data);
}
void tst_LanguageServerProtocol::fromJsonValue()