diff options
author | BogDan Vatra <bogdan@kde.org> | 2021-10-29 14:08:49 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2021-10-29 12:17:53 +0000 |
commit | fd0291df92447e46cb980f62c8f45e878c29f6d0 (patch) | |
tree | 2ed87a282dac783534dcf5539a29892bae826502 /src/plugins/texteditor | |
parent | a8bc9774f9c1948c603ec23daf47d4c4af67f23f (diff) |
Make TextDocument::cleanWhitespace super fast
On documents with a lot of lines of code (e.g. ~30k) saving the
documents takes ages (+6 seconds).
With this change the time is reduced to less than 150ms.
Change-Id: I8a40253a91ae40a6681d5acf1f09711c9b63bd6f
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/textdocument.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index d9b37a1214e..cee8e3cf314 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -835,7 +835,7 @@ void TextDocument::cleanWhitespace(const QTextCursor &cursor) void TextDocument::cleanWhitespace(QTextCursor &cursor, bool inEntireDocument, bool cleanIndentation) { - const QString fileName(filePath().fileName()); + const bool removeTrailingWhitespace = d->m_storageSettings.removeTrailingWhitespace(filePath().fileName()); auto documentLayout = qobject_cast<TextDocumentLayout*>(d->m_document.documentLayout()); Q_ASSERT(cursor.visualNavigation() == false); @@ -862,7 +862,7 @@ void TextDocument::cleanWhitespace(QTextCursor &cursor, bool inEntireDocument, foreach (block, blocks) { QString blockText = block.text(); - if (d->m_storageSettings.removeTrailingWhitespace(fileName)) + if (removeTrailingWhitespace) TabSettings::removeTrailingWhitespace(cursor, block); const int indent = indentations[block.blockNumber()]; |