LanguageClient: optimize cloning documents

Cloning the document that is needed to track the changes for the
language server is 3 times slower than just getting the whole original
document content and create a new QTextDocument with that content.
Presumably some additional information gets cloned that is not needed
for just the content tracking.

Change-Id: I4a7002b2ac97563f01dc3a67351b9363e9cc7b3f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-03-30 13:53:29 +02:00
parent 93fb8cd1ef
commit 4b606ba9de

View File

@@ -618,7 +618,7 @@ void Client::openDocument(TextEditor::TextDocument *document)
}
}
d->m_openedDocument[document].document = document->document()->clone(this);
d->m_openedDocument[document].document = new QTextDocument(document->document()->toPlainText());
d->m_openedDocument[document].contentsChangedConnection
= connect(document,
&TextDocument::contentsChangedWithPosition,