summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-08-08 09:50:11 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-08-08 09:50:11 (GMT)
commit434719c1ae0de5d43f184aefc75ea992093ebfdb (patch)
tree171719ffb5382d04060cdc0a4b10cb71cf2a3e7e
parent2f0f1080eee7b518cd2fa01289f6e218f56b46e9 (diff)
parent857202824e7d6083eeb87fc52d3770f8fd82b559 (diff)
downloadQt-434719c1ae0de5d43f184aefc75ea992093ebfdb.zip
Qt-434719c1ae0de5d43f184aefc75ea992093ebfdb.tar.gz
Qt-434719c1ae0de5d43f184aefc75ea992093ebfdb.tar.bz2
Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qt-fire-team
* 'master' of git://scm.dev.nokia.troll.no/qt/qt-fire-team: Minor optimizations for QTextEngine
-rw-r--r--src/gui/text/qtextengine.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 093b43d..9301f16 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1532,33 +1532,40 @@ void QTextEngine::itemize() const
const ushort *e = uc + length;
int lastScript = QUnicodeTables::Common;
while (uc < e) {
- int script = QUnicodeTables::script(*uc);
- if (script == QUnicodeTables::Inherited)
- script = lastScript;
- analysis->flags = QScriptAnalysis::None;
- if (*uc == QChar::ObjectReplacementCharacter) {
+ switch (*uc) {
+ case QChar::ObjectReplacementCharacter:
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::Object;
- } else if (*uc == QChar::LineSeparator) {
+ break;
+ case QChar::LineSeparator:
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;
if (option.flags() & QTextOption::ShowLineAndParagraphSeparators)
*const_cast<ushort*>(uc) = 0x21B5; // visual line separator
- } else if (*uc == 9) {
+ break;
+ case 9: // Tab
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::Tab;
analysis->bidiLevel = control.baseLevel();
- } else if ((*uc == 32 || *uc == QChar::Nbsp)
- && (option.flags() & QTextOption::ShowTabsAndSpaces)) {
- analysis->script = QUnicodeTables::Common;
- analysis->flags = QScriptAnalysis::Space;
- analysis->bidiLevel = control.baseLevel();
- } else {
- analysis->script = script;
+ break;
+ case 32: // Space
+ case QChar::Nbsp:
+ if (option.flags() & QTextOption::ShowTabsAndSpaces) {
+ analysis->script = QUnicodeTables::Common;
+ analysis->flags = QScriptAnalysis::Space;
+ analysis->bidiLevel = control.baseLevel();
+ break;
+ }
+ // fall through
+ default:
+ int script = QUnicodeTables::script(*uc);
+ analysis->script = script == QUnicodeTables::Inherited ? lastScript : script;
+ analysis->flags = QScriptAnalysis::None;
+ break;
}
lastScript = analysis->script;
++uc;
@@ -2426,7 +2433,7 @@ void QTextEngine::indexAdditionalFormats()
between the text that gets truncated and the ellipsis. This is important to get
correctly shaped results for arabic text.
*/
-static bool nextCharJoins(const QString &string, int pos)
+static inline bool nextCharJoins(const QString &string, int pos)
{
while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing)
++pos;
@@ -2435,13 +2442,14 @@ static bool nextCharJoins(const QString &string, int pos)
return string.at(pos).joining() != QChar::OtherJoining;
}
-static bool prevCharJoins(const QString &string, int pos)
+static inline bool prevCharJoins(const QString &string, int pos)
{
while (pos > 0 && string.at(pos - 1).category() == QChar::Mark_NonSpacing)
--pos;
if (pos == 0)
return false;
- return (string.at(pos - 1).joining() == QChar::Dual || string.at(pos - 1).joining() == QChar::Center);
+ QChar::Joining joining = string.at(pos - 1).joining();
+ return (joining == QChar::Dual || joining == QChar::Center);
}
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags) const