summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <[email protected]>2015-11-21 01:04:39 +0400
committerKonstantin Ritt <[email protected]>2015-11-23 18:52:46 +0000
commitfa00afe7d760d91cf9c91f57dd2f77625e758e28 (patch)
treeb6c947fdc3f69c893592c3dd43ed8cbca0e30f43 /src/gui/text/qtextlayout.cpp
parent073a16e50e5803fc92dc46bca704f8a7ef79e597 (diff)
Optimize QTextEngine::findItem() usage cases
Since the item positions are guaranteed to grow, we could safely re-use the obtained first item while looking for the last item in the chain. Change-Id: I5e42f5de820c62a51a109a4b227b031c697aa898 Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 67af3d316bd..5f570fea824 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2685,7 +2685,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
// add the items left of the cursor
int firstItem = eng->findItem(line.from);
- int lastItem = eng->findItem(lineEnd - 1);
+ int lastItem = eng->findItem(lineEnd - 1, itm);
int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;
QVarLengthArray<int> visualOrder(nItems);
@@ -2786,7 +2786,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
return line.from;
int firstItem = eng->findItem(line.from);
- int lastItem = eng->findItem(line.from + line_length - 1);
+ int lastItem = eng->findItem(line.from + line_length - 1, firstItem);
int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;
if (!nItems)