From ff8347a4b16f000be628c5e10d03a1e1c17537eb Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 17 Jun 2015 16:38:51 -0700 Subject: Replace some Release() calls with virtual destructors. A virtual method that does |delete this| is an anti-pattern. Some classes can be de-virtualized instead. Throw in some unique_ptrs and delete dead code for good measure. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1192013002. --- core/src/fxcodec/codec/fx_codec.cpp | 42 +++++++------------------------------ 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'core/src/fxcodec') diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index db95053efd..9bbcce105f 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -7,33 +7,13 @@ #include "../../../include/fxcodec/fx_codec.h" #include "codec_int.h" CCodec_ModuleMgr::CCodec_ModuleMgr() -{ - m_pBasicModule = new CCodec_BasicModule; - m_pFaxModule = new CCodec_FaxModule; - m_pJpegModule = new CCodec_JpegModule; - m_pJpxModule = new CCodec_JpxModule; - m_pJbig2Module = new CCodec_Jbig2Module; - m_pIccModule = new CCodec_IccModule; - m_pFlateModule = new CCodec_FlateModule; -} -CCodec_ModuleMgr::~CCodec_ModuleMgr() -{ - delete m_pBasicModule; - delete m_pFaxModule; - delete m_pJpegModule; - delete m_pFlateModule; - delete m_pJpxModule; - delete m_pJbig2Module; - delete m_pIccModule; -} -void CCodec_ModuleMgr::InitJbig2Decoder() -{ -} -void CCodec_ModuleMgr::InitJpxDecoder() -{ -} -void CCodec_ModuleMgr::InitIccDecoder() -{ + : m_pBasicModule(new CCodec_BasicModule), + m_pFaxModule(new CCodec_FaxModule), + m_pJpegModule(new CCodec_JpegModule), + m_pJpxModule(new CCodec_JpxModule), + m_pJbig2Module(new CCodec_Jbig2Module), + m_pIccModule(new CCodec_IccModule), + m_pFlateModule(new CCodec_FlateModule) { } CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() { @@ -241,14 +221,6 @@ FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, { return FALSE; } -CCodec_ModuleMgr* CCodec_ModuleMgr::Create() -{ - return new CCodec_ModuleMgr; -} -void CCodec_ModuleMgr::Destroy() -{ - delete this; -} class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { public: -- cgit v1.2.3