diff options
author | tsepez <tsepez@chromium.org> | 2017-01-23 11:01:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-01-23 11:01:42 -0800 |
commit | c757d9a6f90bb879ce2cdd4a756b7b0e1885eb25 (patch) | |
tree | 34847e86907f80d508598eadbb13b463395b49fe /xfa/fde/xml | |
parent | 82aa396188ec26f22fe730f4e35b5a54ebffb5dc (diff) | |
download | pdfium-c757d9a6f90bb879ce2cdd4a756b7b0e1885eb25.tar.xz |
Remove some |void Release() { delete this; }| anti-pattern.
m_pSyntaxParser was unused.
Review-Url: https://codereview.chromium.org/2646203002
Diffstat (limited to 'xfa/fde/xml')
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 39 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.h | 8 |
2 files changed, 6 insertions, 41 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index 2bdaf5155f..e54b4167f6 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -84,10 +84,6 @@ CFDE_XMLNode::CFDE_XMLNode() m_pPrior(nullptr), m_pNext(nullptr) {} -void CFDE_XMLNode::Release() { - delete this; -} - FDE_XMLNODETYPE CFDE_XMLNode::GetType() const { return FDE_XMLNODE_Unknown; } @@ -99,9 +95,9 @@ CFDE_XMLNode::~CFDE_XMLNode() { void CFDE_XMLNode::DeleteChildren() { CFDE_XMLNode* pChild = m_pChild; while (pChild) { - CFDE_XMLNode* pTemp = pChild->m_pNext; - pChild->Release(); - pChild = pTemp; + CFDE_XMLNode* pNext = pChild->m_pNext; + delete pChild; + pChild = pNext; } m_pChild = nullptr; } @@ -529,10 +525,6 @@ CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) ASSERT(m_wsTarget.GetLength() > 0); } -void CFDE_XMLInstruction::Release() { - delete this; -} - FDE_XMLNODETYPE CFDE_XMLInstruction::GetType() const { return FDE_XMLNODE_Instruction; } @@ -687,10 +679,6 @@ CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) CFDE_XMLElement::~CFDE_XMLElement() {} -void CFDE_XMLElement::Release() { - delete this; -} - FDE_XMLNODETYPE CFDE_XMLElement::GetType() const { return FDE_XMLNODE_Element; } @@ -899,10 +887,6 @@ void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) : CFDE_XMLNode(), m_wsText(wsText) {} -void CFDE_XMLText::Release() { - delete this; -} - FDE_XMLNODETYPE CFDE_XMLText::GetType() const { return FDE_XMLNODE_Text; } @@ -917,10 +901,6 @@ CFDE_XMLText::~CFDE_XMLText() {} CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} -void CFDE_XMLCharData::Release() { - delete this; -} - FDE_XMLNODETYPE CFDE_XMLCharData::GetType() const { return FDE_XMLNODE_CharData; } @@ -932,8 +912,7 @@ CFDE_XMLNode* CFDE_XMLCharData::Clone(bool bRecursive) { CFDE_XMLCharData::~CFDE_XMLCharData() {} -CFDE_XMLDoc::CFDE_XMLDoc() - : m_pRoot(nullptr), m_pSyntaxParser(nullptr), m_pXMLParser(nullptr) { +CFDE_XMLDoc::CFDE_XMLDoc() : m_pRoot(nullptr) { Reset(true); CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml"); m_pRoot->InsertChildNode(pXML); @@ -952,20 +931,14 @@ void CFDE_XMLDoc::Reset(bool bInitRoot) { else m_pRoot = new CFDE_XMLNode; } else { - if (m_pRoot) { - m_pRoot->Release(); - m_pRoot = nullptr; - } + delete m_pRoot; + m_pRoot = nullptr; } ReleaseParser(); } void CFDE_XMLDoc::ReleaseParser() { m_pXMLParser.reset(); - if (m_pSyntaxParser) { - m_pSyntaxParser->Release(); - m_pSyntaxParser = nullptr; - } } bool CFDE_XMLDoc::LoadXML(std::unique_ptr<IFDE_XMLParser> pXMLParser) { diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h index 49c5c51f77..41e84bad17 100644 --- a/xfa/fde/xml/fde_xml_imp.h +++ b/xfa/fde/xml/fde_xml_imp.h @@ -44,7 +44,6 @@ class CFDE_XMLNode { CFDE_XMLNode(); virtual ~CFDE_XMLNode(); - virtual void Release(); virtual FDE_XMLNODETYPE GetType() const; virtual CFDE_XMLNode* Clone(bool bRecursive); @@ -79,7 +78,6 @@ class CFDE_XMLInstruction : public CFDE_XMLNode { ~CFDE_XMLInstruction() override; // CFDE_XMLNode - void Release() override; FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(bool bRecursive) override; @@ -115,7 +113,6 @@ class CFDE_XMLElement : public CFDE_XMLNode { ~CFDE_XMLElement() override; // CFDE_XMLNode - void Release() override; FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(bool bRecursive) override; @@ -157,7 +154,6 @@ class CFDE_XMLText : public CFDE_XMLNode { ~CFDE_XMLText() override; // CFDE_XMLNode - void Release() override; FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(bool bRecursive) override; @@ -178,7 +174,6 @@ class CFDE_XMLCharData : public CFDE_XMLDeclaration { explicit CFDE_XMLCharData(const CFX_WideString& wsCData); ~CFDE_XMLCharData() override; - void Release() override; FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(bool bRecursive) override; @@ -210,7 +205,6 @@ class CFDE_XMLDoc { CFX_RetainPtr<IFGAS_Stream> m_pStream; int32_t m_iStatus; CFDE_XMLNode* m_pRoot; - CFDE_XMLSyntaxParser* m_pSyntaxParser; std::unique_ptr<IFDE_XMLParser> m_pXMLParser; }; @@ -227,7 +221,6 @@ class CFDE_BlockBuffer { bool InitBuffer(int32_t iBufferSize = 1024 * 1024); bool IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } - void ReleaseBuffer() { delete this; } FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); inline int32_t GetAllocStep() const { return m_iAllocStep; } inline int32_t& GetDataLengthRef() { return m_iDataLength; } @@ -261,7 +254,6 @@ class CFDE_XMLSyntaxParser { CFDE_XMLSyntaxParser(); ~CFDE_XMLSyntaxParser(); - void Release() { delete this; } void Init(const CFX_RetainPtr<IFGAS_Stream>& pStream, int32_t iXMLPlaneSize, int32_t iTextDataSize = 256); |