From f58b6f62614357ef3a6f171a9f5c89d72981ac40 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 18 Oct 2018 21:04:03 +0000 Subject: Remove some useless calls to the CFX_XMLNode ctor from subclasses. Also fix some nits: - Make member variable names consistent. - Make member variables const. - Make trivial getters return const-ref. Change-Id: Ibd34c9bc58ec0eed3edfc3a8ea39b533a41cad73 Reviewed-on: https://pdfium-review.googlesource.com/c/44151 Reviewed-by: Ryan Harrison Commit-Queue: Ryan Harrison --- core/fxcrt/xml/cfx_xmlelement.cpp | 3 +-- core/fxcrt/xml/cfx_xmlelement.h | 4 ++-- core/fxcrt/xml/cfx_xmlinstruction.cpp | 8 ++++---- core/fxcrt/xml/cfx_xmlinstruction.h | 6 +++--- core/fxcrt/xml/cfx_xmltext.cpp | 5 ++--- core/fxcrt/xml/cfx_xmltext.h | 6 +++--- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index 434b474df7..87e50f4703 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -14,8 +14,7 @@ #include "core/fxcrt/xml/cfx_xmldocument.h" #include "core/fxcrt/xml/cfx_xmltext.h" -CFX_XMLElement::CFX_XMLElement(const WideString& wsTag) - : CFX_XMLNode(), name_(wsTag) { +CFX_XMLElement::CFX_XMLElement(const WideString& wsTag) : name_(wsTag) { ASSERT(!name_.IsEmpty()); } diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h index 8a8720fa83..822f5ec132 100644 --- a/core/fxcrt/xml/cfx_xmlelement.h +++ b/core/fxcrt/xml/cfx_xmlelement.h @@ -24,7 +24,7 @@ class CFX_XMLElement final : public CFX_XMLNode { CFX_XMLNode* Clone(CFX_XMLDocument* doc) override; void Save(const RetainPtr& pXMLStream) override; - WideString GetName() const { return name_; } + const WideString& GetName() const { return name_; } const std::map& GetAttributes() const { return attrs_; @@ -48,7 +48,7 @@ class CFX_XMLElement final : public CFX_XMLNode { private: WideString AttributeToString(const WideString& name, const WideString& value); - WideString name_; + const WideString name_; std::map attrs_; }; diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp index e0af2d1c95..fb534e3732 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.cpp +++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp @@ -13,7 +13,7 @@ #include "core/fxcrt/xml/cfx_xmldocument.h" CFX_XMLInstruction::CFX_XMLInstruction(const WideString& wsTarget) - : CFX_XMLNode(), name_(wsTarget) {} + : name_(wsTarget) {} CFX_XMLInstruction::~CFX_XMLInstruction() = default; @@ -23,12 +23,12 @@ FX_XMLNODETYPE CFX_XMLInstruction::GetType() const { CFX_XMLNode* CFX_XMLInstruction::Clone(CFX_XMLDocument* doc) { auto* node = doc->CreateNode(name_); - node->m_TargetData = m_TargetData; + node->target_data_ = target_data_; return node; } void CFX_XMLInstruction::AppendData(const WideString& wsData) { - m_TargetData.push_back(wsData); + target_data_.push_back(wsData); } bool CFX_XMLInstruction::IsOriginalXFAVersion() const { @@ -50,7 +50,7 @@ void CFX_XMLInstruction::Save( pXMLStream->WriteString(name_.UTF8Encode().AsStringView()); pXMLStream->WriteString(" "); - for (const WideString& target : m_TargetData) { + for (const WideString& target : target_data_) { pXMLStream->WriteString(target.UTF8Encode().AsStringView()); pXMLStream->WriteString(" "); } diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h index c6096a7c46..6221da14d4 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.h +++ b/core/fxcrt/xml/cfx_xmlinstruction.h @@ -27,12 +27,12 @@ class CFX_XMLInstruction final : public CFX_XMLNode { bool IsOriginalXFAVersion() const; bool IsAcrobat() const; - const std::vector& GetTargetData() const { return m_TargetData; } + const std::vector& GetTargetData() const { return target_data_; } void AppendData(const WideString& wsData); private: - WideString name_; - std::vector m_TargetData; + const WideString name_; + std::vector target_data_; }; inline CFX_XMLInstruction* ToXMLInstruction(CFX_XMLNode* pNode) { diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp index c835680580..b6c1be7b07 100644 --- a/core/fxcrt/xml/cfx_xmltext.cpp +++ b/core/fxcrt/xml/cfx_xmltext.cpp @@ -8,8 +8,7 @@ #include "core/fxcrt/xml/cfx_xmldocument.h" -CFX_XMLText::CFX_XMLText(const WideString& wsText) - : CFX_XMLNode(), m_wsText(wsText) {} +CFX_XMLText::CFX_XMLText(const WideString& wsText) : text_(wsText) {} CFX_XMLText::~CFX_XMLText() = default; @@ -18,7 +17,7 @@ FX_XMLNODETYPE CFX_XMLText::GetType() const { } CFX_XMLNode* CFX_XMLText::Clone(CFX_XMLDocument* doc) { - return doc->CreateNode(m_wsText); + return doc->CreateNode(text_); } void CFX_XMLText::Save(const RetainPtr& pXMLStream) { diff --git a/core/fxcrt/xml/cfx_xmltext.h b/core/fxcrt/xml/cfx_xmltext.h index 3e15c5ce9a..f2c7c88d72 100644 --- a/core/fxcrt/xml/cfx_xmltext.h +++ b/core/fxcrt/xml/cfx_xmltext.h @@ -22,11 +22,11 @@ class CFX_XMLText : public CFX_XMLNode { CFX_XMLNode* Clone(CFX_XMLDocument* doc) override; void Save(const RetainPtr& pXMLStream) override; - WideString GetText() const { return m_wsText; } - void SetText(const WideString& wsText) { m_wsText = wsText; } + const WideString& GetText() const { return text_; } + void SetText(const WideString& wsText) { text_ = wsText; } private: - WideString m_wsText; + WideString text_; }; inline bool IsXMLText(const CFX_XMLNode* pNode) { -- cgit v1.2.3