[Libreoffice-commits] core.git: starmath/inc starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Mar 22 12:25:46 UTC 2017


 starmath/inc/parse.hxx    |    2 +-
 starmath/source/parse.cxx |   19 +++++++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

New commits:
commit 19c4103fa5731a7fecc9657a83c5c917c0f8e162
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Mar 22 19:56:43 2017 +0900

    starmath: Make DoOpSubSup() return SmNode
    
    This spares a pair of push and pop of the stack.
    
    Change-Id: I046402c2e975a6b5f4148960a9daffa15cc55ff3
    Reviewed-on: https://gerrit.libreoffice.org/35532
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index 1b96c159ed70..6c3e7dbe7a78 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -68,7 +68,7 @@ class SmParser
     void    DoSum();
     void    DoProduct();
     SmNode *DoSubSup(TG nActiveGroup, SmNode *pGivenNode);
-    void    DoOpSubSup();
+    SmNode *DoOpSubSup();
     void    DoPower();
     SmBlankNode *DoBlank();
     SmNode *DoTerm(bool bGroupNumberIdent);
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index b9f7fde0c746..9a147f48ee37 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1069,8 +1069,7 @@ void SmParser::DoRelation()
         std::unique_ptr<SmStructureNode> pSNode(new SmBinHorNode(m_aCurToken));
         SmNode *pFirst = popOrZero(m_aNodeStack);
 
-        DoOpSubSup();
-        SmNode *pSecond = popOrZero(m_aNodeStack);
+        SmNode *pSecond = DoOpSubSup();
 
         DoSum();
 
@@ -1087,8 +1086,7 @@ void SmParser::DoSum()
         std::unique_ptr<SmStructureNode> pSNode(new SmBinHorNode(m_aCurToken));
         SmNode *pFirst = popOrZero(m_aNodeStack);
 
-        DoOpSubSup();
-        SmNode *pSecond = popOrZero(m_aNodeStack);
+        SmNode *pSecond = DoOpSubSup();
 
         DoProduct();
 
@@ -1152,8 +1150,7 @@ void SmParser::DoProduct()
             default:
                 pSNode = new SmBinHorNode(m_aCurToken);
 
-                DoOpSubSup();
-                pOper = popOrZero(m_aNodeStack);
+                pOper = DoOpSubSup();
         }
 
         DoPower();
@@ -1231,7 +1228,7 @@ SmNode *SmParser::DoSubSup(TG nActiveGroup, SmNode *pGivenNode)
     return pNode.release();
 }
 
-void SmParser::DoOpSubSup()
+SmNode *SmParser::DoOpSubSup()
 {
     // get operator symbol
     auto pNode = o3tl::make_unique<SmMathSymbolNode>(m_aCurToken);
@@ -1239,9 +1236,8 @@ void SmParser::DoOpSubSup()
     NextToken();
     // get sub- supscripts if any
     if (m_aCurToken.nGroup == TG::Power)
-        m_aNodeStack.emplace_front(DoSubSup(TG::Power, pNode.release()));
-    else
-        m_aNodeStack.push_front(std::move(pNode));
+        return DoSubSup(TG::Power, pNode.release());
+    return pNode.release();
 }
 
 void SmParser::DoPower()
@@ -1653,8 +1649,7 @@ SmStructureNode *SmParser::DoUnOper()
         case TMINUSPLUS :
         case TNEG :
         case TFACT :
-            DoOpSubSup();
-            pOper = popOrZero(m_aNodeStack);
+            pOper = DoOpSubSup();
             break;
 
         default :


More information about the Libreoffice-commits mailing list