diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-03-01 13:43:37 (GMT) |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-03-02 09:59:19 (GMT) |
commit | 62faec229dfe654872d3791bee0a27e5290fff4c (patch) | |
tree | 62f698d89338ab72ec77ea8754a14a4949a85b6a /src/gui | |
parent | b7a79ea08be3e127058be549ed354d6276e32e0f (diff) | |
download | Qt-62faec229dfe654872d3791bee0a27e5290fff4c.zip Qt-62faec229dfe654872d3791bee0a27e5290fff4c.tar.gz Qt-62faec229dfe654872d3791bee0a27e5290fff4c.tar.bz2 |
minor optimization: don't mark contents as dirty if nothing was changed
Merge-request: 481
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index d3db2a1..28af5bb 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -95,6 +95,8 @@ public: void QSyntaxHighlighterPrivate::applyFormatChanges() { + bool formatsChanged = false; + QTextLayout *layout = currentBlock.layout(); QList<QTextLayout::FormatRange> ranges = layout->additionalFormats(); @@ -110,6 +112,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() ++it; } else { it = ranges.erase(it); + formatsChanged = true; } } } @@ -147,6 +150,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } ranges << r; + formatsChanged = true; r.start = -1; } @@ -161,9 +165,13 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } ranges << r; + formatsChanged = true; } - layout->setAdditionalFormats(ranges); + if (formatsChanged) { + layout->setAdditionalFormats(ranges); + doc->markContentsDirty(currentBlock.position(), currentBlock.length()); + } } void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded) @@ -214,8 +222,6 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) q->highlightBlock(block.text()); applyFormatChanges(); - doc->markContentsDirty(block.position(), block.length()); - currentBlock = QTextBlock(); } |