[Libreoffice-commits] core.git: connectivity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 17 06:23:08 UTC 2018


 connectivity/source/drivers/file/FNoException.cxx |    6 --
 connectivity/source/drivers/file/fanalyzer.cxx    |    2 
 connectivity/source/drivers/file/fcomp.cxx        |   46 +++++++++++-----------
 connectivity/source/drivers/mork/MQueryHelper.hxx |    8 ---
 connectivity/source/inc/file/fcomp.hxx            |    2 
 5 files changed, 26 insertions(+), 38 deletions(-)

New commits:
commit 7125c6798f94a8b7345372ba36dbabd89bab8820
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 16 10:31:35 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 17 08:22:41 2018 +0200

    loplugin:useuniqueptr in connectivity/file
    
    Change-Id: I39c3b164c78a10f7a499974db3690d062dc59753
    Reviewed-on: https://gerrit.libreoffice.org/59223
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx
index dfb080dc4ee3..bd17c4fc85ba 100644
--- a/connectivity/source/drivers/file/FNoException.cxx
+++ b/connectivity/source/drivers/file/FNoException.cxx
@@ -49,10 +49,6 @@ OPredicateInterpreter::~OPredicateInterpreter()
 
 void OPredicateCompiler::Clean()
 {
-    for(OCodeList::reverse_iterator aIter = m_aCodeList.rbegin(); aIter != m_aCodeList.rend();++aIter)
-    {
-        delete *aIter;
-    }
     m_aCodeList.clear();
 }
 
@@ -61,7 +57,7 @@ void OSQLAnalyzer::bindParameterRow(OValueRefRow const & _pRow)
     OCodeList& rCodeList    = m_aCompiler->m_aCodeList;
     for (auto const& code : rCodeList)
     {
-        OOperandParam* pParam = dynamic_cast<OOperandParam*>(code);
+        OOperandParam* pParam = dynamic_cast<OOperandParam*>(code.get());
         if ( pParam )
             pParam->bindValue(_pRow);
     }
diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx
index accd53ab6809..15fe2c431b7f 100644
--- a/connectivity/source/drivers/file/fanalyzer.cxx
+++ b/connectivity/source/drivers/file/fanalyzer.cxx
@@ -119,7 +119,7 @@ void OSQLAnalyzer::bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow)
 {
     for (auto const& code : rCodeList)
     {
-        OOperandAttr* pAttr = dynamic_cast<OOperandAttr*>(code);
+        OOperandAttr* pAttr = dynamic_cast<OOperandAttr*>(code.get());
         if (pAttr)
         {
             pAttr->bindValue(_pRow);
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index ec6f1622f94a..bdb46456fc38 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -152,10 +152,10 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode const * pPredicateNode)
 
         if (SQL_ISTOKEN(pPredicateNode->getChild(1),OR))                // OR-Operator
         {
-            m_aCodeList.push_back(new OOp_OR);
+            m_aCodeList.emplace_back(new OOp_OR);
         }
         else if (SQL_ISTOKEN(pPredicateNode->getChild(1),AND))      // AND-Operator
-            m_aCodeList.push_back(new OOp_AND);
+            m_aCodeList.emplace_back(new OOp_AND);
         else
         {
             OSL_FAIL("OPredicateCompiler: Error in Parse Tree");
@@ -164,7 +164,7 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode const * pPredicateNode)
     else if (SQL_ISRULE(pPredicateNode,boolean_factor))
     {
         execute(pPredicateNode->getChild(1));
-        m_aCodeList.push_back(new OOp_NOT);
+        m_aCodeList.emplace_back(new OOp_NOT);
     }
     else if (SQL_ISRULE(pPredicateNode,comparison_predicate))
     {
@@ -188,10 +188,10 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode const * pPredicateNode)
         execute(pPredicateNode->getChild(2));                           // process the right branch
         if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"+"))
         {
-            m_aCodeList.push_back(new OOp_ADD);
+            m_aCodeList.emplace_back(new OOp_ADD);
         }
         else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"-"))
-            m_aCodeList.push_back(new OOp_SUB);
+            m_aCodeList.emplace_back(new OOp_SUB);
         else
         {
             OSL_FAIL("OPredicateCompiler: Error in Parse Tree num_value_exp");
@@ -203,10 +203,10 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode const * pPredicateNode)
         execute(pPredicateNode->getChild(2));                           // process the right branch
         if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"*"))
         {
-            m_aCodeList.push_back(new OOp_MUL);
+            m_aCodeList.emplace_back(new OOp_MUL);
         }
         else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"/"))
-            m_aCodeList.push_back(new OOp_DIV);
+            m_aCodeList.emplace_back(new OOp_DIV);
         else
         {
             OSL_FAIL("OPredicateCompiler: Error in Parse Tree num_value_exp");
@@ -261,7 +261,7 @@ void OPredicateCompiler::execute_COMPARE(OSQLParseNode const * pPredicateNode)
 
     execute(pPredicateNode->getChild(0));
     execute(pPredicateNode->getChild(2));
-    m_aCodeList.push_back( new OOp_COMPARE(ePredicateType) );
+    m_aCodeList.emplace_back( new OOp_COMPARE(ePredicateType) );
 }
 
 
@@ -310,7 +310,7 @@ void OPredicateCompiler::execute_LIKE(OSQLParseNode const * pPredicateNode)
     OBoolOperator* pOperator = bNotLike
                                     ? new OOp_NOTLIKE(cEscape)
                                     : new OOp_LIKE(cEscape);
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 }
 
 void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode)
@@ -335,12 +335,12 @@ void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode)
     OOperand* pColumnOp = execute(pColumn);
     OOperand* pOb1 = execute(p1stValue);
     OBoolOperator* pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::LESS_EQUAL : SQLFilterOperator::GREATER);
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 
     execute(pColumn);
     OOperand* pOb2 = execute(p2ndtValue);
     pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::GREATER_EQUAL : SQLFilterOperator::LESS);
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 
     if ( pColumnOp && pOb1 && pOb2 )
     {
@@ -387,7 +387,7 @@ void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode)
         pBoolOp = new OOp_OR;
     else
         pBoolOp = new OOp_AND;
-    m_aCodeList.push_back(pBoolOp);
+    m_aCodeList.emplace_back(pBoolOp);
 }
 
 void OPredicateCompiler::execute_ISNULL(OSQLParseNode const * pPredicateNode)
@@ -405,7 +405,7 @@ void OPredicateCompiler::execute_ISNULL(OSQLParseNode const * pPredicateNode)
     execute(pPredicateNode->getChild(0));
     OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::SQLNULL) ?
                                 new OOp_ISNULL : new OOp_ISNOTNULL;
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 }
 
 OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNode)
@@ -527,7 +527,7 @@ OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNo
         m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,nullptr);
     }
     if (pOperand)
-        m_aCodeList.push_back(pOperand);
+        m_aCodeList.emplace_back(pOperand);
     return pOperand;
 }
 
@@ -541,11 +541,11 @@ bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
 
     for (auto const& code : rCodeList)
     {
-        OOperand* pOperand = dynamic_cast<OOperand* >(code);
+        OOperand* pOperand = dynamic_cast<OOperand* >(code.get());
         if (pOperand)
             m_aStack.push(pOperand);
         else
-            static_cast<OOperator *>(code)->Exec(m_aStack);
+            static_cast<OOperator *>(code.get())->Exec(m_aStack);
     }
 
     OOperand* pOperand = m_aStack.top();
@@ -567,11 +567,11 @@ void OPredicateInterpreter::evaluateSelection(OCodeList& rCodeList, ORowSetValue
 
     for (auto const& code : rCodeList)
     {
-        OOperand* pOperand = dynamic_cast<OOperand* >(code);
+        OOperand* pOperand = dynamic_cast<OOperand* >(code.get());
         if (pOperand)
             m_aStack.push(pOperand);
         else
-            static_cast<OOperator *>(code)->Exec(m_aStack);
+            static_cast<OOperator *>(code.get())->Exec(m_aStack);
     }
 
     OOperand* pOperand = m_aStack.top();
@@ -598,7 +598,7 @@ void OPredicateCompiler::execute_Fold(OSQLParseNode const * pPredicateNode)
     else
         pOperator = new OOp_Lower;
 
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 }
 
 void OPredicateCompiler::executeFunction(OSQLParseNode const * pPredicateNode)
@@ -780,7 +780,7 @@ void OPredicateCompiler::executeFunction(OSQLParseNode const * pPredicateNode)
         case SQL_TOKEN_NOW:
         case SQL_TOKEN_WEEK:
             {
-                m_aCodeList.push_back(new OStopOperand);
+                m_aCodeList.emplace_back(new OStopOperand);
                 OSQLParseNode* pList = pPredicateNode->getChild(2);
                 for (size_t i=0; i < pList->count(); ++i)
                     execute(pList->getChild(i));
@@ -850,7 +850,7 @@ void OPredicateCompiler::executeFunction(OSQLParseNode const * pPredicateNode)
             break;
 
         case SQL_TOKEN_SUBSTRING:
-            m_aCodeList.push_back(new OStopOperand);
+            m_aCodeList.emplace_back(new OStopOperand);
             if ( pPredicateNode->count() == 4 ) //char_substring_fct
             {
                 OSQLParseNode* pList = pPredicateNode->getChild(2);
@@ -867,7 +867,7 @@ void OPredicateCompiler::executeFunction(OSQLParseNode const * pPredicateNode)
             break;
 
         case SQL_TOKEN_POSITION:
-            m_aCodeList.push_back(new OStopOperand);
+            m_aCodeList.emplace_back(new OStopOperand);
             if ( pPredicateNode->count() == 4 ) //position_exp
             {
                 OSQLParseNode* pList = pPredicateNode->getChild(2);
@@ -885,7 +885,7 @@ void OPredicateCompiler::executeFunction(OSQLParseNode const * pPredicateNode)
             m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_FUNCTION_NOT_SUPPORTED,nullptr);
     }
 
-    m_aCodeList.push_back(pOperator);
+    m_aCodeList.emplace_back(pOperator);
 }
 
 
diff --git a/connectivity/source/drivers/mork/MQueryHelper.hxx b/connectivity/source/drivers/mork/MQueryHelper.hxx
index cc240d36b0f3..136760e8c052 100644
--- a/connectivity/source/drivers/mork/MQueryHelper.hxx
+++ b/connectivity/source/drivers/mork/MQueryHelper.hxx
@@ -125,14 +125,6 @@ namespace connectivity
                                  m_aExprCondType( OR )
                             {}
 
-            virtual ~MQueryExpression() override {
-                for (ExprVector::iterator i(m_aExprVector.begin());
-                     i != m_aExprVector.end(); ++i)
-                {
-                    delete *i;
-                }
-            }
-
         private:
             ExprVector          m_aExprVector;
             bool_cond           m_aExprCondType;
diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx
index bc1b452e1915..5b290c2f7212 100644
--- a/connectivity/source/inc/file/fcomp.hxx
+++ b/connectivity/source/inc/file/fcomp.hxx
@@ -31,7 +31,7 @@ namespace connectivity
         class OCode;
         class OOperand;
         class OSQLAnalyzer;
-        typedef std::vector<OCode*> OCodeList;
+        typedef std::vector<std::unique_ptr<OCode>> OCodeList;
 
         class OPredicateCompiler final : public ::salhelper::SimpleReferenceObject
         {


More information about the Libreoffice-commits mailing list