diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-03-01 13:43:35 (GMT) |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-03-02 09:59:18 (GMT) |
commit | b7a79ea08be3e127058be549ed354d6276e32e0f (patch) | |
tree | 7aa1f4330dfeeee56f4d7becc775df1d1f65d663 /src/gui/text | |
parent | b49eaedbe81011483ce52af71e9ebf29c61cef43 (diff) | |
download | Qt-b7a79ea08be3e127058be549ed354d6276e32e0f.zip Qt-b7a79ea08be3e127058be549ed354d6276e32e0f.tar.gz Qt-b7a79ea08be3e127058be549ed354d6276e32e0f.tar.bz2 |
minor optimization: ignore invalid preeditAreaPosition/preeditAreaText
Merge-request: 481
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 1dc8e23..d3db2a1 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -102,20 +102,22 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() const int preeditAreaStart = layout->preeditAreaPosition(); const int preeditAreaLength = layout->preeditAreaText().length(); - QList<QTextLayout::FormatRange>::Iterator it = ranges.begin(); - while (it != ranges.end()) { - if (it->start >= preeditAreaStart - && it->start + it->length <= preeditAreaStart + preeditAreaLength) { - ++it; - } else { - it = ranges.erase(it); + if (preeditAreaLength != 0) { + QList<QTextLayout::FormatRange>::Iterator it = ranges.begin(); + while (it != ranges.end()) { + if (it->start >= preeditAreaStart + && it->start + it->length <= preeditAreaStart + preeditAreaLength) { + ++it; + } else { + it = ranges.erase(it); + } } } QTextCharFormat emptyFormat; QTextLayout::FormatRange r; - r.start = r.length = -1; + r.start = -1; int i = 0; while (i < formatChanges.count()) { @@ -137,22 +139,26 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() r.length = i - r.start; - if (r.start >= preeditAreaStart) - r.start += preeditAreaLength; - else if (r.start + r.length >= preeditAreaStart) - r.length += preeditAreaLength; + if (preeditAreaLength != 0) { + if (r.start >= preeditAreaStart) + r.start += preeditAreaLength; + else if (r.start + r.length >= preeditAreaStart) + r.length += preeditAreaLength; + } ranges << r; - r.start = r.length = -1; + r.start = -1; } if (r.start != -1) { r.length = formatChanges.count() - r.start; - if (r.start >= preeditAreaStart) - r.start += preeditAreaLength; - else if (r.start + r.length >= preeditAreaStart) - r.length += preeditAreaLength; + if (preeditAreaLength != 0) { + if (r.start >= preeditAreaStart) + r.start += preeditAreaLength; + else if (r.start + r.length >= preeditAreaStart) + r.length += preeditAreaLength; + } ranges << r; } |