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 --- lotuswordpro/source/filter/lwpbreaksoverride.cxx | 3 +-- lotuswordpro/source/filter/lwpfoundry.cxx | 18 ++++------------ lotuswordpro/source/filter/lwpfrib.cxx | 3 +-- lotuswordpro/source/filter/lwpobj.cxx | 3 +-- .../source/filter/lwpparaborderoverride.cxx | 12 ++++------- lotuswordpro/source/filter/xfilter/xfcell.cxx | 3 +-- lotuswordpro/source/filter/xfilter/xfcellstyle.cxx | 9 +++----- .../source/filter/xfilter/xfconfigmanager.cxx | 6 ++---- .../source/filter/xfilter/xfframestyle.cxx | 24 ++++++++-------------- .../source/filter/xfilter/xfheaderstyle.cxx | 15 +++++--------- lotuswordpro/source/filter/xfilter/xfindex.cxx | 5 ++--- .../source/filter/xfilter/xfmasterpage.cxx | 12 ++++------- .../source/filter/xfilter/xfpagemaster.cxx | 21 +++++++------------ lotuswordpro/source/filter/xfilter/xfparastyle.cxx | 14 +++++-------- lotuswordpro/source/filter/xfilter/xfrow.cxx | 13 +----------- lotuswordpro/source/filter/xfilter/xfrowstyle.cxx | 3 +-- lotuswordpro/source/filter/xfilter/xfsaxstream.cxx | 3 +-- .../source/filter/xfilter/xfsectionstyle.cxx | 9 +++----- .../source/filter/xfilter/xfstylemanager.cxx | 3 +-- .../source/filter/xfilter/xftablestyle.cxx | 6 ++---- 20 files changed, 57 insertions(+), 128 deletions(-) (limited to 'lotuswordpro') diff --git a/lotuswordpro/source/filter/lwpbreaksoverride.cxx b/lotuswordpro/source/filter/lwpbreaksoverride.cxx index 12a855ab3748..23f7f83a1f51 100644 --- a/lotuswordpro/source/filter/lwpbreaksoverride.cxx +++ b/lotuswordpro/source/filter/lwpbreaksoverride.cxx @@ -79,8 +79,7 @@ LwpBreaksOverride::LwpBreaksOverride(LwpBreaksOverride const& rOther) LwpBreaksOverride::~LwpBreaksOverride() { - if( m_pNextStyle ) - delete m_pNextStyle; + delete m_pNextStyle; } LwpBreaksOverride* LwpBreaksOverride::clone() const diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx index d343520ae96e..7e90c366d781 100644 --- a/lotuswordpro/source/filter/lwpfoundry.cxx +++ b/lotuswordpro/source/filter/lwpfoundry.cxx @@ -91,20 +91,10 @@ LwpFoundry::LwpFoundry(LwpObjectStream *pStrm, LwpDocument* pDoc) LwpFoundry::~LwpFoundry() { - if(m_pPieceMgr) - { - delete m_pPieceMgr; - } - if(m_pStyleMgr) - { - delete m_pStyleMgr; - } - if (m_pDropcapMgr) - delete m_pDropcapMgr; - if (m_pBulletStyleMgr) - { - delete m_pBulletStyleMgr; - } + delete m_pPieceMgr; + delete m_pStyleMgr; + delete m_pDropcapMgr; + delete m_pBulletStyleMgr; } void LwpFoundry::Read(LwpObjectStream *pStrm) diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx index f93066082438..851a3db27d53 100644 --- a/lotuswordpro/source/filter/lwpfrib.cxx +++ b/lotuswordpro/source/filter/lwpfrib.cxx @@ -102,8 +102,7 @@ LwpFrib::LwpFrib(LwpPara* pPara) LwpFrib::~LwpFrib() { - if(m_pModifiers) - delete m_pModifiers; + delete m_pModifiers; } LwpFrib* LwpFrib::CreateFrib(LwpPara* pPara, LwpObjectStream* pObjStrm, sal_uInt8 fribtag,sal_uInt8 editID) diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx index 7e15b6265fe3..5a0a79b3615c 100644 --- a/lotuswordpro/source/filter/lwpobj.cxx +++ b/lotuswordpro/source/filter/lwpobj.cxx @@ -74,8 +74,7 @@ LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm) */ LwpObject::~LwpObject() { - if(m_pObjStrm) - delete m_pObjStrm; + delete m_pObjStrm; } /** diff --git a/lotuswordpro/source/filter/lwpparaborderoverride.cxx b/lotuswordpro/source/filter/lwpparaborderoverride.cxx index 318ff8d40f4c..254dc092c192 100644 --- a/lotuswordpro/source/filter/lwpparaborderoverride.cxx +++ b/lotuswordpro/source/filter/lwpparaborderoverride.cxx @@ -113,14 +113,10 @@ LwpParaBorderOverride::LwpParaBorderOverride(LwpParaBorderOverride const& rOther LwpParaBorderOverride::~LwpParaBorderOverride() { - if( m_pBorderStuff ) - delete m_pBorderStuff; - if( m_pBetweenStuff ) - delete m_pBetweenStuff; - if( m_pShadow ) - delete m_pShadow; - if( m_pMargins ) - delete m_pMargins; + delete m_pBorderStuff; + delete m_pBetweenStuff; + delete m_pShadow; + delete m_pMargins; } LwpParaBorderOverride* LwpParaBorderOverride::clone() const diff --git a/lotuswordpro/source/filter/xfilter/xfcell.cxx b/lotuswordpro/source/filter/xfilter/xfcell.cxx index ac79dda1e331..a263a6355ce6 100644 --- a/lotuswordpro/source/filter/xfilter/xfcell.cxx +++ b/lotuswordpro/source/filter/xfilter/xfcell.cxx @@ -75,8 +75,7 @@ XFCell::XFCell() XFCell::~XFCell() { - if( m_pSubTable ) - delete m_pSubTable; + delete m_pSubTable; } void XFCell::Add(XFContent *pContent) diff --git a/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx index b0d4881162b0..a6350e2f1f65 100644 --- a/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx @@ -74,8 +74,7 @@ XFCellStyle::XFCellStyle() XFCellStyle::~XFCellStyle() { - if( m_pBorders ) - delete m_pBorders; + delete m_pBorders; } void XFCellStyle::SetPadding(double left, double right,double top, double bottom) @@ -97,15 +96,13 @@ void XFCellStyle::SetBackColor(XFColor& color) void XFCellStyle::SetBackImage(XFBGImage *pImage) { - if( m_pBackImage ) - delete m_pBackImage; + delete m_pBackImage; m_pBackImage = pImage; } void XFCellStyle::SetBorders(XFBorders *pBorders) { - if( m_pBorders ) - delete m_pBorders; + delete m_pBorders; m_pBorders = pBorders; } diff --git a/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx index 6b218bc42671..dab6c9da91c7 100644 --- a/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx +++ b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx @@ -76,15 +76,13 @@ XFConfigManager::~XFConfigManager() void XFConfigManager::SetLineNumberConfig(XFLineNumberConfig *pLNConfig) { - if( m_pLineNumberConfig ) - delete m_pLineNumberConfig; + delete m_pLineNumberConfig; m_pLineNumberConfig = pLNConfig; } void XFConfigManager::SetFootnoteConfig(XFFootnoteConfig *pFNConfig) { - if( m_pFootnoteConfig ) - delete m_pFootnoteConfig; + delete m_pFootnoteConfig; m_pFootnoteConfig = pFNConfig; } diff --git a/lotuswordpro/source/filter/xfilter/xfframestyle.cxx b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx index a0b485b002f6..b11ce54694e2 100644 --- a/lotuswordpro/source/filter/xfilter/xfframestyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx @@ -89,41 +89,33 @@ XFFrameStyle::XFFrameStyle() XFFrameStyle::~XFFrameStyle() { - if( m_pBorders ) - delete m_pBorders; - if( m_pColumns ) - delete m_pColumns; - if( m_pShadow ) - delete m_pShadow; - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBorders; + delete m_pColumns; + delete m_pShadow; + delete m_pBGImage; } void XFFrameStyle::SetBorders(XFBorders *pBorders) { - if( m_pBorders ) - delete m_pBorders; + delete m_pBorders; m_pBorders = pBorders; } void XFFrameStyle::SetColumns(XFColumns *pColumns) { - if( m_pColumns ) - delete m_pColumns; + delete m_pColumns; m_pColumns = pColumns; } void XFFrameStyle::SetShadow(XFShadow *pShadow) { - if( m_pShadow ) - delete m_pShadow; + delete m_pShadow; m_pShadow = pShadow; } void XFFrameStyle::SetBackImage(XFBGImage *image) { - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBGImage; m_pBGImage = image; } diff --git a/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx index 10345c886d83..d2521ab9bf39 100644 --- a/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx @@ -73,12 +73,9 @@ XFHeaderStyle::XFHeaderStyle(bool isFooter) XFHeaderStyle::~XFHeaderStyle() { - if( m_pBorders ) - delete m_pBorders; - if( m_pBGImage ) - delete m_pBGImage; - if( m_pShadow ) - delete m_pShadow; + delete m_pBorders; + delete m_pBGImage; + delete m_pShadow; } void XFHeaderStyle::SetMargins(double left, double right, double bottom) @@ -114,15 +111,13 @@ void XFHeaderStyle::SetShadow(XFShadow *pShadow) void XFHeaderStyle::SetBorders(XFBorders *pBorders) { - if( m_pBorders ) - delete m_pBorders; + delete m_pBorders; m_pBorders = pBorders; } void XFHeaderStyle::SetBackImage(XFBGImage *image) { - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBGImage; m_pBGImage = image; } diff --git a/lotuswordpro/source/filter/xfilter/xfindex.cxx b/lotuswordpro/source/filter/xfilter/xfindex.cxx index 40d64feefd9b..a028aa919120 100644 --- a/lotuswordpro/source/filter/xfilter/xfindex.cxx +++ b/lotuswordpro/source/filter/xfilter/xfindex.cxx @@ -76,8 +76,7 @@ XFIndex::XFIndex() XFIndex::~XFIndex() { - if( m_pTitle ) - delete m_pTitle; + delete m_pTitle; for(sal_uInt16 i=1;iGetCol(); - if( col<1 ) - { - pCell->SetCol(m_aCells.size()+1); - } - - col = pCell->GetCol(); - if( m_aCells.find(col) != m_aCells.end() ) - delete m_aCells[col]; -*/ sal_Int32 col = m_aCells.size()+1; pCell->SetCol(col); pCell->SetOwnerRow(this); diff --git a/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx b/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx index ffeaa0603440..a8acfbadc490 100644 --- a/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx @@ -108,8 +108,7 @@ XFRowStyle& XFRowStyle::operator=(XFRowStyle const &other) m_fMinHeight = other.m_fMinHeight; m_aBackColor = other.m_aBackColor; - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBGImage; if( other.m_pBGImage ) m_pBGImage = new XFBGImage(*other.m_pBGImage); diff --git a/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx index 9419630d4650..6a5bcd7ccc4a 100644 --- a/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx +++ b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx @@ -87,8 +87,7 @@ XFSaxStream::XFSaxStream(Reference& xHandler) XFSaxStream::~XFSaxStream() { - if( m_pAttrList ) - delete m_pAttrList; + delete m_pAttrList; } void XFSaxStream::StartDocument() diff --git a/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx b/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx index dd04e8662054..cb9d5cf972f9 100644 --- a/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx @@ -70,10 +70,8 @@ XFSectionStyle::XFSectionStyle() XFSectionStyle::~XFSectionStyle() { - if( m_pColumns ) - delete m_pColumns; - if( m_pBackImage ) - delete m_pBackImage; + delete m_pColumns; + delete m_pBackImage; } enumXFStyle XFSectionStyle::GetStyleFamily() @@ -93,8 +91,7 @@ void XFSectionStyle::SetMarginRight(double right) void XFSectionStyle::SetColumns(XFColumns *pColumns) { - if( m_pColumns ) - delete m_pColumns; + delete m_pColumns; m_pColumns = pColumns; } diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx index 6a31a9cd1f73..8704816b3fc3 100644 --- a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx +++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx @@ -203,8 +203,7 @@ IXFStyleRet XFStyleManager::AddStyle(IXFStyle *pStyle) } else if( pStyle->GetStyleFamily() == enumXFStyleOutline ) { - if( s_pOutlineStyle ) - delete s_pOutlineStyle; + delete s_pOutlineStyle; s_pOutlineStyle = pStyle; } else if( pStyle->GetStyleFamily() == enumXFStyleStrokeDash ) diff --git a/lotuswordpro/source/filter/xfilter/xftablestyle.cxx b/lotuswordpro/source/filter/xfilter/xftablestyle.cxx index 0fc87b216541..0e055515c25e 100644 --- a/lotuswordpro/source/filter/xfilter/xftablestyle.cxx +++ b/lotuswordpro/source/filter/xfilter/xftablestyle.cxx @@ -69,14 +69,12 @@ XFTableStyle::XFTableStyle() XFTableStyle::~XFTableStyle() { - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBGImage; } void XFTableStyle::SetBackImage(XFBGImage *pImage) { - if( m_pBGImage ) - delete m_pBGImage; + delete m_pBGImage; m_pBGImage = pImage; } -- cgit