From 4df55209c2f922f33c2f69fadfff5d30026e89d2 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 2 Mar 2017 09:47:08 -0800 Subject: Remove CFX_MassArrayTemplate backing array. The map is one-to-one, so no need for a pointer to an externally stored rect. Change-Id: I4cd6f728cdadeb4c7b25b6f34f5d50bb5db89623 Reviewed-on: https://pdfium-review.googlesource.com/2896 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fgas/font/cfgas_gefont.cpp | 41 +++++++++++++++++------------------------ xfa/fgas/font/cfgas_gefont.h | 3 +-- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index a175202e7d..a57962d084 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -220,8 +220,6 @@ bool CFGAS_GEFont::InitFont() { m_pCharWidthMap = pdfium::MakeUnique>(1024); } - if (!m_pRectArray) - m_pRectArray = pdfium::MakeUnique>(16); return true; } @@ -315,32 +313,27 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, CFX_Rect* bbox, bool bRecursive, bool bCharCode) { - ASSERT(m_pRectArray); - CFX_Rect* pRect = nullptr; auto it = m_BBoxMap.find(wUnicode); - if (it == m_BBoxMap.end()) { - CFX_RetainPtr pFont; - int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont) { - if (pFont.Get() == this) { - FX_RECT rtBBox; - if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { - CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); - int32_t index = m_pRectArray->Add(rt); - pRect = m_pRectArray->GetPtrAt(index); - m_BBoxMap[wUnicode] = pRect; - } - } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) { - return true; - } - } - } else { - pRect = it->second; + if (it != m_BBoxMap.end()) { + *bbox = it->second; + return true; } - if (!pRect) + + CFX_RetainPtr pFont; + int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); + if (!pFont || iGlyph == 0xFFFF) + return false; + + if (pFont.Get() != this) + return pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode); + + FX_RECT rtBBox; + if (!m_pFont->GetGlyphBBox(iGlyph, rtBBox)) return false; - *bbox = *pRect; + CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); + m_BBoxMap[wUnicode] = rt; + *bbox = rt; return true; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index 6c9d890df4..2201721a93 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -109,8 +109,7 @@ class CFGAS_GEFont : public CFX_Retainable { CFX_RetainPtr m_pFileRead; std::unique_ptr m_pFontEncoding; std::unique_ptr> m_pCharWidthMap; - std::unique_ptr> m_pRectArray; - std::map m_BBoxMap; // Rect owned by m_pRectArray. + std::map m_BBoxMap; CXFA_PDFFontMgr* m_pProvider; // not owned. std::vector> m_SubstFonts; std::map> m_FontMapper; -- cgit v1.2.3