diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2016-07-21 17:57:28 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2016-07-22 00:47:25 +0000 |
commit | f045d14791a84f478c40fbd6b0590f527b36cbff (patch) | |
tree | e487df8284f916fd83343922470ed0eda461c348 /starmath | |
parent | a3609cf5a8f724dc43f3b1dcd3e413b657001570 (diff) |
starmath: Return early if the cursor locates after a text node
No longer create unnecessary copy of nodes.
Change-Id: Icf8cdd3ce0f9ebbf7159e9e7eaea7abe52c05060
Reviewed-on: https://gerrit.libreoffice.org/27366
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/cursor.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index bef900af6ed4..b1ef0b0e9495 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -354,16 +354,17 @@ SmNodeList::iterator SmCursor::FindPositionInLineList(SmNodeList* pLineList, if(rCaretPos.Index > 0) { SmTextNode* pText = static_cast<SmTextNode*>(rCaretPos.pSelectedNode); + if (rCaretPos.Index == pText->GetText().getLength()) + return ++it; OUString str1 = pText->GetText().copy(0, rCaretPos.Index); OUString str2 = pText->GetText().copy(rCaretPos.Index); pText->ChangeText(str1); ++it; //Insert str2 as new text node - if(!str2.isEmpty()){ - SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc()); - pNewText->ChangeText(str2); - it = pLineList->insert(it, pNewText); - } + assert(!str2.isEmpty()); + SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc()); + pNewText->ChangeText(str2); + it = pLineList->insert(it, pNewText); } }else ++it; |