starmath: Simplify code with std::unique_ptr
Change-Id: I2f6f993b92ae7f2f89b2d9d6c89b51d827226a3d Reviewed-on: https://gerrit.libreoffice.org/29554 Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp> Tested-by: Takeshi Abe <tabe@fixedpoint.jp>
This commit is contained in:
parent
8daf6707ef
commit
33c57f1550
@ -1935,9 +1935,7 @@ void SmParser::DoBrace()
|
||||
assert(m_aCurToken.eType == TLEFT || TokenInGroup(TG::LBrace));
|
||||
|
||||
std::unique_ptr<SmStructureNode> pSNode(new SmBraceNode(m_aCurToken));
|
||||
SmNode *pBody = nullptr,
|
||||
*pLeft = nullptr,
|
||||
*pRight = nullptr;
|
||||
std::unique_ptr<SmNode> pBody, pLeft, pRight;
|
||||
SmScaleMode eScaleMode = SCALE_NONE;
|
||||
SmParseError eError = PE_NONE;
|
||||
|
||||
@ -1949,11 +1947,11 @@ void SmParser::DoBrace()
|
||||
// check for left bracket
|
||||
if (TokenInGroup(TG::LBrace) || TokenInGroup(TG::RBrace))
|
||||
{
|
||||
pLeft = new SmMathSymbolNode(m_aCurToken);
|
||||
pLeft.reset(new SmMathSymbolNode(m_aCurToken));
|
||||
|
||||
NextToken();
|
||||
DoBracebody(true);
|
||||
pBody = popOrZero(m_aNodeStack);
|
||||
pBody.reset(popOrZero(m_aNodeStack));
|
||||
|
||||
if (m_aCurToken.eType == TRIGHT)
|
||||
{ NextToken();
|
||||
@ -1961,7 +1959,7 @@ void SmParser::DoBrace()
|
||||
// check for right bracket
|
||||
if (TokenInGroup(TG::LBrace) || TokenInGroup(TG::RBrace))
|
||||
{
|
||||
pRight = new SmMathSymbolNode(m_aCurToken);
|
||||
pRight.reset(new SmMathSymbolNode(m_aCurToken));
|
||||
NextToken();
|
||||
}
|
||||
else
|
||||
@ -1977,11 +1975,11 @@ void SmParser::DoBrace()
|
||||
{
|
||||
assert(TokenInGroup(TG::LBrace));
|
||||
|
||||
pLeft = new SmMathSymbolNode(m_aCurToken);
|
||||
pLeft.reset(new SmMathSymbolNode(m_aCurToken));
|
||||
|
||||
NextToken();
|
||||
DoBracebody(false);
|
||||
pBody = popOrZero(m_aNodeStack);
|
||||
pBody.reset(popOrZero(m_aNodeStack));
|
||||
|
||||
SmTokenType eExpectedType = TUNKNOWN;
|
||||
switch (pLeft->GetToken().eType)
|
||||
@ -2000,7 +1998,7 @@ void SmParser::DoBrace()
|
||||
|
||||
if (m_aCurToken.eType == eExpectedType)
|
||||
{
|
||||
pRight = new SmMathSymbolNode(m_aCurToken);
|
||||
pRight.reset(new SmMathSymbolNode(m_aCurToken));
|
||||
NextToken();
|
||||
}
|
||||
else
|
||||
@ -2008,22 +2006,16 @@ void SmParser::DoBrace()
|
||||
}
|
||||
|
||||
if (eError == PE_NONE)
|
||||
{ OSL_ENSURE(pLeft, "Sm: NULL pointer");
|
||||
OSL_ENSURE(pRight, "Sm: NULL pointer");
|
||||
pSNode->SetSubNodes(pLeft, pBody, pRight);
|
||||
{
|
||||
assert(pLeft);
|
||||
assert(pRight);
|
||||
pSNode->SetSubNodes(pLeft.release(), pBody.release(), pRight.release());
|
||||
pSNode->SetScaleMode(eScaleMode);
|
||||
m_aNodeStack.push_front(std::move(pSNode));
|
||||
}
|
||||
else
|
||||
{
|
||||
pSNode.reset();
|
||||
delete pBody;
|
||||
delete pLeft;
|
||||
delete pRight;
|
||||
|
||||
Error(eError);
|
||||
}
|
||||
}
|
||||
|
||||
void SmParser::DoBracebody(bool bIsLeftRight)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user