LanguageClient: improve the performance of creating text marks

If we already know the document for a text mark we can save the lookup
in the documentModel. This improves the performance for the text mark
creation on windows by around 10%.

Change-Id: Iecf9cb2e9114ed026f5e354e75d279b54c0ce51d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-06-13 10:40:17 +02:00
parent e973257cbc
commit 3c2d545230
8 changed files with 34 additions and 19 deletions

View File

@@ -710,11 +710,11 @@ class ClangdDiagnosticManager : public LanguageClient::DiagnosticManager
});
}
TextMark *createTextMark(const Utils::FilePath &filePath,
TextMark *createTextMark(TextDocument *doc,
const Diagnostic &diagnostic,
bool isProjectFile) const override
{
return new ClangdTextMark(filePath, diagnostic, isProjectFile, getClient());
return new ClangdTextMark(doc, diagnostic, isProjectFile, getClient());
}
};

View File

@@ -263,16 +263,16 @@ Task createTask(const ClangDiagnostic &diagnostic)
} // anonymous namespace
ClangdTextMark::ClangdTextMark(const FilePath &filePath,
ClangdTextMark::ClangdTextMark(TextEditor::TextDocument *doc,
const Diagnostic &diagnostic,
bool isProjectFile,
ClangdClient *client)
: TextEditor::TextMark(filePath,
: TextEditor::TextMark(doc,
int(diagnostic.range().start().line() + 1),
{client->name(), client->id()})
, m_lspDiagnostic(diagnostic)
, m_diagnostic(
convertDiagnostic(ClangdDiagnostic(diagnostic), filePath, client->hostPathMapper()))
convertDiagnostic(ClangdDiagnostic(diagnostic), doc->filePath(), client->hostPathMapper()))
, m_client(client)
{
setSettingsPage(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID);

View File

@@ -23,7 +23,7 @@ class ClangdClient;
class ClangdTextMark : public TextEditor::TextMark
{
public:
ClangdTextMark(const ::Utils::FilePath &filePath,
ClangdTextMark(TextEditor::TextDocument *doc,
const LanguageServerProtocol::Diagnostic &diagnostic,
bool isProjectFile,
ClangdClient *client);