From e0ad6a4af5d9c5f5671a9ecd0aa437dedae52b16 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 15 Apr 2016 14:32:49 -0700 Subject: Avoid narrowing to StringC in CPDF_Name and CPDF_NameTree Remove redundant CPDF_Name constructors given promotion rules. Rework one char* in CPDF_PageContentGenerator. Review URL: https://codereview.chromium.org/1890973006 --- core/fpdfdoc/doc_basic.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'core/fpdfdoc/doc_basic.cpp') diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index a3e94cb033..a0c6b2babc 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -71,12 +71,19 @@ FX_FLOAT CPDF_Dest::GetParam(int index) { CFX_ByteString CPDF_Dest::GetRemoteName() { return m_pObj ? m_pObj->GetString() : CFX_ByteString(); } + CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, - const CFX_ByteStringC& category) { - if (pDoc->GetRoot() && pDoc->GetRoot()->GetDictBy("Names")) - m_pRoot = pDoc->GetRoot()->GetDictBy("Names")->GetDictBy(category); - else - m_pRoot = NULL; + const CFX_ByteString& category) + : m_pRoot(nullptr) { + CPDF_Dictionary* pRoot = pDoc->GetRoot(); + if (!pRoot) + return; + + CPDF_Dictionary* pNames = pRoot->GetDictBy("Names"); + if (!pNames) + return; + + m_pRoot = pNames->GetDictBy(category); } static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, @@ -233,7 +240,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const { return SearchNameNode(m_pRoot, csName, nIndex, NULL); } CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, - const CFX_ByteStringC& sName) { + const CFX_ByteString& sName) { CPDF_Object* pValue = LookupValue(sName); if (!pValue) { CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests"); -- cgit v1.2.3