summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Kling <andreas.kling@nokia.com>2010-03-04 08:58:56 (GMT)
committerAndreas Kling <andreas.kling@nokia.com>2010-03-04 09:02:15 (GMT)
commitfa882a7cb91aca4574f0e939068fd37716a923c7 (patch)
treea5d11f1bbe42072ef57afcb350bec53d6c5fea8f
parentb0323ac9e117397509de898b21d63767eddfb289 (diff)
downloadQt-fa882a7cb91aca4574f0e939068fd37716a923c7.zip
Qt-fa882a7cb91aca4574f0e939068fd37716a923c7.tar.gz
Qt-fa882a7cb91aca4574f0e939068fd37716a923c7.tar.bz2
Avoid QString reallocation in QTextEngine
Calling QString::utf16() will cause reallocation (for null-termination) if the string was created via fromRawData(). Reviewed-by: Benjamin Poulain Reviewed-by: Simon Hausmann
-rw-r--r--src/gui/text/qtextengine.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 02eae98..b826588 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -81,7 +81,7 @@ public:
void generate(int start, int length, QFont::Capitalization caps)
{
if ((int)caps == (int)QFont::SmallCaps)
- generateScriptItemsSmallCaps(m_string.utf16(), start, length);
+ generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length);
else if(caps == QFont::Capitalize)
generateScriptItemsCapitalize(start, length);
else if(caps != QFont::MixedCase) {
@@ -1434,9 +1434,7 @@ void QTextEngine::itemize() const
layoutData->hasBidi = bidiItemize(const_cast<QTextEngine *>(this), analysis, control);
}
- const ushort *unicode = layoutData->string.utf16();
- // correctly assign script, isTab and isObject to the script analysis
- const ushort *uc = unicode;
+ const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode());
const ushort *e = uc + length;
int lastScript = QUnicodeTables::Common;
while (uc < e) {