From 4729774b244db7a175077ed0c70aa48be62bc60e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 13 Jun 2015 22:15:31 +0200 Subject: 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 --- sd/source/core/sdpage.cxx | 3 +-- sd/source/filter/html/pubdlg.cxx | 3 +-- sd/source/ui/animations/CustomAnimationDialog.cxx | 6 ++---- sd/source/ui/unoidl/unopback.cxx | 3 +-- sd/source/ui/view/outlview.cxx | 11 +++-------- 5 files changed, 8 insertions(+), 18 deletions(-) (limited to 'sd') diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 5a8de34029fe..80cd7520bbfc 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -145,8 +145,7 @@ SdPage::~SdPage() EndListenOutlineText(); - if( mpItems ) - delete mpItems; + delete mpItems; Clear(); } diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx index 033eeb0fe52b..9bdf9cf915f0 100644 --- a/sd/source/filter/html/pubdlg.cxx +++ b/sd/source/filter/html/pubdlg.cxx @@ -1549,8 +1549,7 @@ bool SdPublishingDlg::Load() bool bOk = pIStm && ( pIStm->GetError() == 0); - if( pIStm ) - delete pIStm; + delete pIStm; if( !bOk ) return false; diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx index 633427ec3e80..f0bf4bf81c1e 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationDialog.cxx @@ -2217,8 +2217,7 @@ void CustomAnimationDialog::dispose() STLPropertySet* CustomAnimationDialog::getResultSet() { - if( mpResultSet ) - delete mpResultSet; + delete mpResultSet; mpResultSet = createDefaultSet(); @@ -2292,8 +2291,7 @@ PropertyControl::~PropertyControl() void PropertyControl::dispose() { - if( mpSubControl ) - delete mpSubControl; + delete mpSubControl; ListBox::dispose(); } diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 53be94336ebf..899388a4c9c6 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -75,8 +75,7 @@ SdUnoPageBackground::~SdUnoPageBackground() throw() if( mpDoc ) EndListening( *mpDoc ); - if( mpSet ) - delete mpSet; + delete mpSet; } void SdUnoPageBackground::Notify( SfxBroadcaster&, const SfxHint& rHint ) diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 455640e1a0e1..7d985036bcec 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -175,8 +175,7 @@ OutlineView::~OutlineView() mrOutlineViewShell.GetViewShellBase().GetEventMultiplexer()->RemoveEventListener( aLink ); DisconnectFromApplication(); - if( mpProgress ) - delete mpProgress; + delete mpProgress; // unregister OutlinerViews and destroy them for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++) @@ -604,9 +603,7 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner ) if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD) { - if( mpProgress ) - delete mpProgress; - + delete mpProgress; mpProgress = new SfxProgress( GetDocSh(), SD_RESSTR(STR_CREATE_PAGES), mnPagesToProcess ); } else @@ -1196,9 +1193,7 @@ IMPL_LINK_NOARG(OutlineView, RemovingPagesHdl) if (mnPagesToProcess) { - if( mpProgress ) - delete mpProgress; - + delete mpProgress; mpProgress = new SfxProgress( GetDocSh(), SD_RESSTR(STR_DELETE_PAGES), mnPagesToProcess ); } mrOutliner.UpdateFields(); -- cgit