From 8fb78b12219fb0b9c949f8c5bda558f0bd20cc9d Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Fri, 2 Dec 2011 22:03:36 +0400 Subject: visual formula editor: optimize some buildings a bit --- starmath/source/cursor.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'starmath') 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; -- cgit v1.2.3