summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2010-12-23 13:31:54 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2010-12-23 13:31:54 (GMT)
commit26d2580daab37f4a6ff595a5f18b8a49249b5da1 (patch)
tree461f5698f9dda89ddbe3e2e65037087be8ef8509 /src/gui
parent090b9eb37f067b28ff667dc2f84022fa2664902a (diff)
downloadQt-26d2580daab37f4a6ff595a5f18b8a49249b5da1.zip
Qt-26d2580daab37f4a6ff595a5f18b8a49249b5da1.tar.gz
Qt-26d2580daab37f4a6ff595a5f18b8a49249b5da1.tar.bz2
improve performance of QTextEngine, esp. setBoundary by using non-detaching operator[]
Improves scrolling in testfile content.xml attached to QTBUG-9549. According to callgrind, the improvement is nearly 35% (comparing total incl. cost of QTextEngine::setBoundary) total incl cost / calls to setBoundary = before: 6.0883269E9 / 46520 = approx. 130875.47 after: 2.4834313E9 / 29370 = approx. 84556.733 in relation this gives us: 84556.733 / 130875.47 = approx. 0.64608542 Merge-request: 975 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextengine.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 3bd6122..17d5fc1 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -894,16 +894,16 @@ void QTextEngine::shapeText(int item) const
if (letterSpacingIsAbsolute)
glyphs.advances_x[i-1] += letterSpacing;
else {
- const QFixed advance = glyphs.advances_x[i-1];
- glyphs.advances_x[i-1] += (letterSpacing - 100) * advance / 100;
+ QFixed &advance = glyphs.advances_x[i-1];
+ advance += (letterSpacing - 100) * advance / 100;
}
}
}
if (letterSpacingIsAbsolute)
glyphs.advances_x[si.num_glyphs-1] += letterSpacing;
else {
- const QFixed advance = glyphs.advances_x[si.num_glyphs-1];
- glyphs.advances_x[si.num_glyphs-1] += (letterSpacing - 100) * advance / 100;
+ QFixed &advance = glyphs.advances_x[si.num_glyphs-1];
+ advance += (letterSpacing - 100) * advance / 100;
}
}
if (wordSpacing != 0) {
@@ -2521,14 +2521,14 @@ void QTextEngine::setBoundary(int strPos) const
return;
int itemToSplit = 0;
- while (itemToSplit < layoutData->items.size() && layoutData->items[itemToSplit].position <= strPos)
+ while (itemToSplit < layoutData->items.size() && layoutData->items.at(itemToSplit).position <= strPos)
itemToSplit++;
itemToSplit--;
- if (layoutData->items[itemToSplit].position == strPos) {
+ if (layoutData->items.at(itemToSplit).position == strPos) {
// already a split at the requested position
return;
}
- splitItem(itemToSplit, strPos - layoutData->items[itemToSplit].position);
+ splitItem(itemToSplit, strPos - layoutData->items.at(itemToSplit).position);
}
void QTextEngine::splitItem(int item, int pos) const