diff options
author | tsepez <tsepez@chromium.org> | 2017-01-06 09:48:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-01-06 09:48:18 -0800 |
commit | 6fd07ef0a817dca5acbcadea41b8f880376f339a (patch) | |
tree | e330419f0289e503478bffc7638e836e113a7fe7 /xfa/fgas/font/cfgas_fontmgr.cpp | |
parent | 8d94b6687f27e1238f352939434704f75b330c1d (diff) | |
download | pdfium-6fd07ef0a817dca5acbcadea41b8f880376f339a.tar.xz |
Remove CFX_MapPtrToPtr in xfa/fgas, part 2
Review-Url: https://codereview.chromium.org/2616623005
Diffstat (limited to 'xfa/fgas/font/cfgas_fontmgr.cpp')
-rw-r--r-- | xfa/fgas/font/cfgas_fontmgr.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 1849441a16..9d3954fb1e 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -575,14 +575,6 @@ CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum) CFGAS_FontMgr::~CFGAS_FontMgr() { for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) delete m_InstalledFonts[i]; - FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); - while (pos) { - uint32_t dwHash; - CFX_FontDescriptorInfos* pDescs; - m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); - delete pDescs; - } - m_Hash2Fonts.clear(); } bool CFGAS_FontMgr::EnumFontsFromFontMapper() { @@ -645,12 +637,13 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByCodePage( if (!pFontArray->empty()) return (*pFontArray)[0]; - CFX_FontDescriptorInfos* sortedFonts = nullptr; - if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { - sortedFonts = new CFX_FontDescriptorInfos; + CFX_FontDescriptorInfos* sortedFonts = m_Hash2CandidateList[dwHash].get(); + if (!sortedFonts) { + auto pNewFonts = pdfium::MakeUnique<CFX_FontDescriptorInfos>(); + sortedFonts = pNewFonts.get(); MatchFonts(*sortedFonts, wCodePage, dwFontStyles, CFX_WideString(pszFontFamily), 0); - m_Hash2CandidateList.SetAt(dwHash, sortedFonts); + m_Hash2CandidateList[dwHash] = std::move(pNewFonts); } if (sortedFonts->GetSize() == 0) return nullptr; @@ -688,12 +681,13 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicode( if (VerifyUnicode((*pFonts)[i], wUnicode)) return (*pFonts)[i]; } - CFX_FontDescriptorInfos* sortedFonts = nullptr; - if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { - sortedFonts = new CFX_FontDescriptorInfos; + CFX_FontDescriptorInfos* sortedFonts = m_Hash2CandidateList[dwHash].get(); + if (!sortedFonts) { + auto pNewFonts = pdfium::MakeUnique<CFX_FontDescriptorInfos>(); + sortedFonts = pNewFonts.get(); MatchFonts(*sortedFonts, wCodePage, dwFontStyles, CFX_WideString(pszFontFamily), wUnicode); - m_Hash2CandidateList.SetAt(dwHash, sortedFonts); + m_Hash2CandidateList[dwHash] = std::move(pNewFonts); } for (int32_t i = 0; i < sortedFonts->GetSize(); ++i) { CFX_FontDescriptor* pDesc = sortedFonts->GetAt(i).pFont; |