diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2015-06-13 22:15:31 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-06-15 14:46:41 +0200 |
commit | 4729774b244db7a175077ed0c70aa48be62bc60e (patch) | |
tree | 9f0f2e329d269835d4c20a8183a2772b734608f3 /sc | |
parent | 9db80b1499e09cde000160434728f7b231c30db8 (diff) |
remove unnecessary check for null when calling delete
Idea originally from caolan.
Found using the following command:
find . -name *.cxx | xargs /opt/local/bin/grep -zlP '(?m)if\s*\(\s*\w+\s*\)\s*delete\s+\w+\;'
Change-Id: I3338f4e22193a6dfd6219c8c75835224a3392763
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/exctools.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/rtf/eeimpars.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportSharedData.cxx | 15 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLStylesExportHelper.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTrackedChangesContext.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/sfiltdlg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/instbdlg.cxx | 3 |
13 files changed, 21 insertions, 44 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4af29d6d1dcd..72b698b47ba2 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1105,8 +1105,7 @@ void ScFormulaCell::Compile( const OUString& rFormula, bool bNoListening, ScCompiler aComp( pDocument, aPos); aComp.SetGrammar(eGrammar); pCode = aComp.CompileString( rFormula ); - if ( pCodeOld ) - delete pCodeOld; + delete pCodeOld; if( !pCode->GetCodeError() ) { if ( !pCode->GetLen() && !aResult.GetHybridFormula().isEmpty() && rFormula == aResult.GetHybridFormula() ) @@ -1140,8 +1139,7 @@ void ScFormulaCell::Compile( ScTokenArray* pCodeOld = pCode; ScCompiler aComp(rCxt, aPos); pCode = aComp.CompileString( rFormula ); - if ( pCodeOld ) - delete pCodeOld; + delete pCodeOld; if( !pCode->GetCodeError() ) { if ( !pCode->GetLen() && !aResult.GetHybridFormula().isEmpty() && rFormula == aResult.GetHybridFormula() ) diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index be1bc8fc5ba0..a1bc8ee56cd5 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -677,8 +677,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if (rInner == nIEnd) break; if (bPositive) ++rInner; else --rInner; } - if ( pNewPattern ) - delete pNewPattern; + delete pNewPattern; // Analyse diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index c8bdc22dab18..7158224e9d68 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3736,14 +3736,11 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, ScInterpreter::~ScInterpreter() { -// delete pStack; - if ( pStackObj == pGlobalStack ) bGlobalStackInUse = false; else delete pStackObj; - if (pTokenMatrixMap) - delete pTokenMatrixMap; + delete pTokenMatrixMap; } void ScInterpreter::SetGlobalConfig(const ScCalcConfig& rConfig) diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 9b316c477d24..5df0787b4768 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -568,8 +568,7 @@ ExcFilterCondition::ExcFilterCondition() : ExcFilterCondition::~ExcFilterCondition() { - if( pText ) - delete pText; + delete pText; } sal_Size ExcFilterCondition::GetTextBytes() const diff --git a/sc/source/filter/excel/exctools.cxx b/sc/source/filter/excel/exctools.cxx index c23c70dab191..6f85f28c3044 100644 --- a/sc/source/filter/excel/exctools.cxx +++ b/sc/source/filter/excel/exctools.cxx @@ -223,12 +223,9 @@ ExcScenario::ExcScenario( XclImpStream& rIn, const RootData& rR ) ExcScenario::~ExcScenario() { - if( pName ) - delete pName; - if( pComment ) - delete pComment; - if( pUserName ) - delete pUserName; + delete pName; + delete pComment; + delete pUserName; } void ExcScenario::Apply( const XclImpRoot& rRoot, const bool bLast ) diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 001286c379c1..ef9a9ff4e4bb 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -464,8 +464,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu } } } - if ( pProgress ) - delete pProgress; + delete pProgress; } bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEParseEntry* pE ) diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index 91788a6b030e..bf0eafd5ad92 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -56,8 +56,7 @@ ScChangeTrackingExportHelper::ScChangeTrackingExportHelper(ScXMLExport& rTempExp ScChangeTrackingExportHelper::~ScChangeTrackingExportHelper() { - if (pDependings) - delete pDependings; + delete pDependings; } OUString ScChangeTrackingExportHelper::GetChangeID(const sal_uInt32 nActionNumber) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index 33c601679266..cbc0442f1292 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -136,8 +136,7 @@ ScMyDelAction::ScMyDelAction(const ScChangeActionType nActionTypeP) ScMyDelAction::~ScMyDelAction() { - if (pInsCutOff) - delete pInsCutOff; + delete pInsCutOff; } ScMyMoveAction::ScMyMoveAction() @@ -149,8 +148,7 @@ ScMyMoveAction::ScMyMoveAction() ScMyMoveAction::~ScMyMoveAction() { - if (pMoveRanges) - delete pMoveRanges; + delete pMoveRanges; } ScMyContentAction::ScMyContentAction() diff --git a/sc/source/filter/xml/XMLExportSharedData.cxx b/sc/source/filter/xml/XMLExportSharedData.cxx index 5f2b06f2244a..0e3fd2c61f50 100644 --- a/sc/source/filter/xml/XMLExportSharedData.cxx +++ b/sc/source/filter/xml/XMLExportSharedData.cxx @@ -37,16 +37,11 @@ ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) : ScMySharedData::~ScMySharedData() { - if (pShapesContainer) - delete pShapesContainer; - if (pTableShapes) - delete pTableShapes; - if (pDrawPages) - delete pDrawPages; - if (pDetectiveObjContainer) - delete pDetectiveObjContainer; - if (pNoteShapes) - delete pNoteShapes; + delete pShapesContainer; + delete pTableShapes; + delete pDrawPages; + delete pDetectiveObjContainer; + delete pNoteShapes; } void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol) diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index 10231fb0a4ef..de8a6a07f5c4 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -339,8 +339,7 @@ void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport, rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace); } } - if (pMessage) - delete pMessage; + delete pMessage; } void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport) diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx index 2232a1f592ad..1499f34d7afc 100644 --- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx +++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx @@ -977,8 +977,7 @@ ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport& rImport, ScXMLChangeTextPContext::~ScXMLChangeTextPContext() { - if (pTextPContext) - delete pTextPContext; + delete pTextPContext; } SvXMLImportContext *ScXMLChangeTextPContext::CreateChildContext( sal_uInt16 nTempPrefix, diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx index 9ae4d34a1e85..ba3eae03833f 100644 --- a/sc/source/ui/dbgui/sfiltdlg.cxx +++ b/sc/source/ui/dbgui/sfiltdlg.cxx @@ -110,8 +110,7 @@ void ScSpecialFilterDlg::dispose() delete pOptionsMgr; - if ( pOutItem ) - delete pOutItem; + delete pOutItem; // Hack: RefInput-Kontrolle pIdle->Stop(); diff --git a/sc/source/ui/miscdlgs/instbdlg.cxx b/sc/source/ui/miscdlgs/instbdlg.cxx index 719f03726188..a237f18d58c1 100644 --- a/sc/source/ui/miscdlgs/instbdlg.cxx +++ b/sc/source/ui/miscdlgs/instbdlg.cxx @@ -281,8 +281,7 @@ IMPL_LINK_NOARG(ScInsertTableDlg, ChoiceHdl_Impl) IMPL_LINK_NOARG(ScInsertTableDlg, BrowseHdl_Impl) { - if ( pDocInserter ) - delete pDocInserter; + delete pDocInserter; pDocInserter = new ::sfx2::DocumentInserter( OUString::createFromAscii( ScDocShell::Factory().GetShortName() ) ); pDocInserter->StartExecuteModal( LINK( this, ScInsertTableDlg, DialogClosedHdl ) ); |