[Libreoffice-commits] core.git: editeng/source io/source sax/source sd/source svtools/source sw/source vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 3 13:29:46 UTC 2018


 editeng/source/rtf/svxrtf.cxx                |    6 ++----
 io/source/stm/omark.cxx                      |    5 +----
 sax/source/tools/fastattribs.cxx             |    3 +--
 sd/source/ui/view/ToolBarManager.cxx         |    5 +----
 svtools/source/svhtml/parhtml.cxx            |    3 +--
 sw/source/core/layout/atrfrm.cxx             |    6 ++----
 sw/source/core/text/pormulti.cxx             |    3 +--
 sw/source/filter/basflt/shellio.cxx          |    3 +--
 sw/source/filter/html/htmlctxt.cxx           |    3 +--
 sw/source/filter/html/htmltab.cxx            |    6 ++----
 sw/source/filter/html/swhtml.cxx             |   27 +++++++++------------------
 sw/source/filter/html/wrthtml.cxx            |   16 +++-------------
 sw/source/filter/ww8/docxattributeoutput.cxx |    3 +--
 vcl/source/edit/texteng.cxx                  |    5 +----
 14 files changed, 27 insertions(+), 67 deletions(-)

New commits:
commit 6725311151403e5bf5bef44e08c35ac76527aba4
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Oct 3 12:47:53 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 3 15:29:19 2018 +0200

    no need to call empty() before clear()
    
    found with
    
        git grep -A2 -nP '!.*\.empty()' | grep -B1 -w clear
    
    Change-Id: I87013eab9c6988048b891d20577e1f7efbce1b6c
    Reviewed-on: https://gerrit.libreoffice.org/61295
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 1c4f7f246d09..53fa36f92698 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -97,10 +97,8 @@ SvParserState SvxRTFParser::CallParser()
 
     if( !aColorTbl.empty() )
         ClearColorTbl();
-    if (!m_FontTable.empty())
-        m_FontTable.clear();
-    if (!m_StyleTable.empty())
-        m_StyleTable.clear();
+    m_FontTable.clear();
+    m_StyleTable.clear();
     if( !aAttrStack.empty() )
         ClearAttrStack();
 
diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index 989c20894b0f..af6b7d390f3f 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -179,10 +179,7 @@ void OMarkableOutputStream::closeOutput()
     MutexGuard guard( m_mutex );
     // all marks must be cleared and all
 
-    if( ! m_mapMarks.empty() )
-    {
-        m_mapMarks.clear();
-     }
+    m_mapMarks.clear();
     m_nCurrentPos = m_pBuffer->getSize();
       checkMarksAndFlush();
 
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 30a764368947..b8d1bacec630 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -74,8 +74,7 @@ void FastAttributeList::clear()
     maAttributeTokens.clear();
     maAttributeValues.resize(1);
     assert(maAttributeValues[0] == 0);
-    if (!maUnknownAttributes.empty())
-        maUnknownAttributes.clear();
+    maUnknownAttributes.clear();
 }
 
 void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength )
diff --git a/sd/source/ui/view/ToolBarManager.cxx b/sd/source/ui/view/ToolBarManager.cxx
index 607249f81023..d82b529ea24c 100644
--- a/sd/source/ui/view/ToolBarManager.cxx
+++ b/sd/source/ui/view/ToolBarManager.cxx
@@ -1203,10 +1203,7 @@ void ToolBarList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup)
     Groups::iterator iGroup (maGroups.find(eGroup));
     if (iGroup != maGroups.end())
     {
-        if ( ! iGroup->second.empty())
-        {
-            iGroup->second.clear();
-        }
+        iGroup->second.clear();
     }
 }
 
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index c80fd00d77ed..6f9e33a8bd2e 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -1029,8 +1029,7 @@ HtmlTokenId HTMLParser::GetNextToken_()
     }
 
     // Delete options
-    if (!maOptions.empty())
-        maOptions.clear();
+    maOptions.clear();
 
     if( !IsParserWorking() )        // Don't continue if already an error occurred
         return HtmlTokenId::NONE;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 9a7f977a7d97..d3af82b5315a 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -836,8 +836,7 @@ SwFormatCol& SwFormatCol::operator=( const SwFormatCol& rCpy )
     m_aWidthAdjustValue = rCpy.m_aWidthAdjustValue;
     m_bOrtho      = rCpy.IsOrtho();
 
-    if ( !m_aColumns.empty() )
-        m_aColumns.clear();
+    m_aColumns.clear();
     for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
     {
         m_aColumns.emplace_back(rCpy.GetColumns()[i] );
@@ -941,8 +940,7 @@ void SwFormatCol::Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16
 {
     // Deleting seems to be a bit radical on the first sight; but otherwise we
     // have to initialize all values of the remaining SwColumns.
-    if ( !m_aColumns.empty() )
-        m_aColumns.clear();
+    m_aColumns.clear();
     for ( sal_uInt16 i = 0; i < nNumCols; ++i )
     {
         m_aColumns.emplace_back( );
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index a3dadc9c1e7c..3e659366264d 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -1290,8 +1290,7 @@ std::unique_ptr<SwMultiCreator> SwTextSizeInfo::GetMultiCreator(TextFrameIndex &
         if( !bOn && !aEnd.empty() )
             n2Start = aEnd.back();
 
-        if( !aEnd.empty() )
-            aEnd.clear();
+        aEnd.clear();
 
         // now, search for the end of the ROTATE portion, similar to above
         bOn = true;
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index c4bd839976fa..6709ceb312ac 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -295,8 +295,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
                     }
                 }
             }
-            if( !aFlyFrameArr.empty() )
-                aFlyFrameArr.clear();
+            aFlyFrameArr.clear();
 
             mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
             if( mxDoc->getIDocumentRedlineAccess().IsRedlineOn() )
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index c329361ee3e7..3b0b5c59565e 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -174,8 +174,7 @@ void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
     // be set here and then the pointers become invalid!
     OSL_ENSURE(m_aParaAttrs.empty(),
         "Danger: there are non-final paragraph attributes");
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     const SwNodeIndex* pOldEndPara = &m_pPam->GetPoint()->nNode;
 #ifndef NDEBUG
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 1db29230c4d5..a056d8dca4d2 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -2815,8 +2815,7 @@ void SectionSaveStruct::Restore( SwHTMLParser& rParser )
     rParser.m_bNoParSpace = false;
     rParser.m_nOpenParaToken = HtmlTokenId::NONE;
 
-    if( !rParser.m_aParaAttrs.empty() )
-        rParser.m_aParaAttrs.clear();
+    rParser.m_aParaAttrs.clear();
 }
 
 class CellSaveStruct : public SectionSaveStruct
@@ -3360,8 +3359,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
                 m_nFontStHeadStart = m_nFontStMin;
 
                 // The hard attributes on that paragraph are never gonna be invalid anymore
-                if( !m_aParaAttrs.empty() )
-                    m_aParaAttrs.clear();
+                m_aParaAttrs.clear();
             }
 
             // create a table context
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index cbda0a8dcbf9..42bdd7be095b 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -691,8 +691,7 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
                 m_nContextStMin = 0;
             }
 
-            if( !m_aParaAttrs.empty() )
-                m_aParaAttrs.clear();
+            m_aParaAttrs.clear();
 
             SetAttr( false );
 
@@ -1236,8 +1235,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
                 // if there are temporary paragraph attributes and the
                 // paragraph isn't empty then the paragraph attributes
                 // are final.
-                if( !m_aParaAttrs.empty() )
-                    m_aParaAttrs.clear();
+                m_aParaAttrs.clear();
 
                 SetAttr();
             }
@@ -1525,8 +1523,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
             // if there are temporary paragraph attributes and the
             // paragraph isn't empty then the paragraph attributes
             // are final.
-            if( !m_aParaAttrs.empty() )
-                m_aParaAttrs.clear();
+            m_aParaAttrs.clear();
 
             SetAttr();
         }
@@ -2139,8 +2136,7 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
         eMode = AM_SPACE;
 
     // the hard attributes of this paragraph will never be invalid again
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     SwTextNode *pTextNode = (AM_SPACE==eMode || AM_NOSPACE==eMode) ?
         m_pPam->GetPoint()->nNode.GetNode().GetTextNode() : nullptr;
@@ -3194,8 +3190,7 @@ void SwHTMLParser::DeleteAttr( HTMLAttr* pAttr )
     // be set here and then the pointers become invalid!
     OSL_ENSURE(m_aParaAttrs.empty(),
         "Danger: there are non-final paragraph attributes");
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     // The list header is saved in the attribute
     HTMLAttr **ppHead = pAttr->ppHead;
@@ -3253,8 +3248,7 @@ void SwHTMLParser::SaveAttrTab(std::shared_ptr<HTMLAttrTable> const & rNewAttrTa
     // be set here and then the pointers become invalid!
     OSL_ENSURE(m_aParaAttrs.empty(),
             "Danger: there are non-final paragraph attributes");
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
     HTMLAttr** pSaveAttributes = reinterpret_cast<HTMLAttr**>(rNewAttrTab.get());
@@ -3281,8 +3275,7 @@ void SwHTMLParser::SplitAttrTab( std::shared_ptr<HTMLAttrTable> const & rNewAttr
     // be set here and then the pointers become invalid!
     OSL_ENSURE(m_aParaAttrs.empty(),
             "Danger: there are non-final paragraph attributes");
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     const SwNodeIndex& nSttIdx = m_pPam->GetPoint()->nNode;
     SwNodeIndex nEndIdx( nSttIdx );
@@ -3381,8 +3374,7 @@ void SwHTMLParser::RestoreAttrTab(std::shared_ptr<HTMLAttrTable> const & rNewAtt
     // be set here and then the pointers become invalid!
     OSL_ENSURE(m_aParaAttrs.empty(),
             "Danger: there are non-final paragraph attributes");
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     HTMLAttr** pHTMLAttributes = reinterpret_cast<HTMLAttr**>(m_xAttrTab.get());
     HTMLAttr** pSaveAttributes = reinterpret_cast<HTMLAttr**>(rNewAttrTab.get());
@@ -5271,8 +5263,7 @@ void SwHTMLParser::InsertHorzRule()
     SetTextCollAttrs(m_aContexts.back().get());
 
     // the hard attributes of the current paragraph will never become invalid
-    if( !m_aParaAttrs.empty() )
-        m_aParaAttrs.clear();
+    m_aParaAttrs.clear();
 
     if( nSize>0 || bColor || bNoShade )
     {
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 3805a41a2329..0d14929ca0c3 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -488,23 +488,13 @@ ErrCode SwHTMLWriter::WriteStream()
 
     m_aHTMLControls.DeleteAndDestroyAll();
 
-    if (!m_CharFormatInfos.empty())
-        m_CharFormatInfos.clear();
-
-    if (!m_TextCollInfos.empty())
-        m_TextCollInfos.clear();
-
-    if(!m_aImgMapNames.empty())
-        m_aImgMapNames.clear();
-
+    m_CharFormatInfos.clear();
+    m_TextCollInfos.clear();
+    m_aImgMapNames.clear();
     m_aImplicitMarks.clear();
-
     m_aOutlineMarks.clear();
-
     m_aOutlineMarkPoss.clear();
-
     m_aNumRuleNames.clear();
-
     m_aScriptParaStyles.clear();
     m_aScriptTextStyles.clear();
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 76e9be65b463..e65a71df4f98 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3562,8 +3562,7 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
 
     // We should clear the TableStyle map. In case of Table inside multiple tables it contains the
     // table border style of the previous table.
-    if (! m_aTableStyleConf.empty())
-        m_aTableStyleConf.clear();
+    m_aTableStyleConf.clear();
 
     // Extract properties from grab bag
     for( const auto & rGrabBagElement : aGrabBag )
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 9d02a83bc9c0..630daf65c906 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -2073,10 +2073,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara )
     {
         if ( !pTEParaPortion->GetTextPortions().empty() )
             pTEParaPortion->GetTextPortions().Reset();
-        if ( !pTEParaPortion->GetLines().empty() )
-        {
-            pTEParaPortion->GetLines().clear();
-        }
+        pTEParaPortion->GetLines().clear();
         CreateAndInsertEmptyLine( nPara );
         pTEParaPortion->SetValid();
         return nOldLineCount != pTEParaPortion->GetLines().size();


More information about the Libreoffice-commits mailing list