diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2011-12-02 22:03:36 +0400 |
---|---|---|
committer | Ivan Timofeev <timofeev.i.s@gmail.com> | 2011-12-04 19:24:57 +0400 |
commit | 8fb78b12219fb0b9c949f8c5bda558f0bd20cc9d (patch) | |
tree | f4ca2c3de0cde291f3efd8222e0677a007a0f89a /starmath | |
parent | 93cf9e1f2b4a269dfe4fd90945dd2f7c50277db5 (diff) |
visual formula editor: optimize some buildings a bit
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/cursor.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index 2f50532ee7cd..b7f518f86a29 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -700,15 +700,14 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) { it = FindPositionInLineList(pLineList, position->CaretPos); //If there's no selected nodes, create a place node + SmNode *pBodyNode; SmCaretPos PosAfterInsert; if(pSelectedNodesList->size() == 0) { - SmNode* pPlace = new SmPlaceNode(); - PosAfterInsert = SmCaretPos(pPlace, 1); - pSelectedNodesList->push_front(pPlace); - } + pBodyNode = new SmPlaceNode(); + PosAfterInsert = SmCaretPos(pBodyNode, 1); + } else + pBodyNode = SmNodeListParser().Parse(pSelectedNodesList); - //Parse body nodes - SmNode *pBodyNode = SmNodeListParser().Parse(pSelectedNodesList); delete pSelectedNodesList; //Create SmBraceNode @@ -959,10 +958,11 @@ void SmCursor::InsertFraction() { it = FindPositionInLineList(pLineList, position->CaretPos); //Create pNum, and pDenom - if(pSelectedNodesList->size() == 0) - pSelectedNodesList->push_front(new SmPlaceNode()); - SmNode *pNum = SmNodeListParser().Parse(pSelectedNodesList), - *pDenom = new SmPlaceNode(); + bool bEmptyFraction = pSelectedNodesList->empty(); + SmNode *pNum = bEmptyFraction + ? new SmPlaceNode() + : SmNodeListParser().Parse(pSelectedNodesList); + SmNode *pDenom = new SmPlaceNode(); delete pSelectedNodesList; pSelectedNodesList = NULL; |