Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1583)

Unified Diff: core/fpdfapi/fpdf_font/cpdf_type3font.cpp

Issue 2169793002: Use smart pointers for CFX_Font and CFX_Type3Font classes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_type3font.h ('k') | core/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_font/cpdf_type3font.cpp
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
index 6c339ea5a723bfb3dd65c9e6309a3f0c151aba94..8e4ac568846fa051a42f86404b3e3f25388e80b6 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
@@ -21,10 +21,7 @@ CPDF_Type3Font::CPDF_Type3Font()
FXSYS_memset(m_CharWidthL, 0, sizeof(m_CharWidthL));
}
-CPDF_Type3Font::~CPDF_Type3Font() {
- for (auto it : m_CacheMap)
- delete it.second;
-}
+CPDF_Type3Font::~CPDF_Type3Font() {}
bool CPDF_Type3Font::IsType3Font() const {
return true;
@@ -94,7 +91,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
auto it = m_CacheMap.find(charcode);
if (it != m_CacheMap.end())
- return it->second;
+ return it->second.get();
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
@@ -116,7 +113,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
pNewChar->m_pForm->ParseContent(nullptr, nullptr, pNewChar.get(), level + 1);
it = m_CacheMap.find(charcode);
if (it != m_CacheMap.end())
- return it->second;
+ return it->second.get();
FX_FLOAT scale = m_FontMatrix.GetXUnit();
pNewChar->m_Width = (int32_t)(pNewChar->m_Width * scale + 0.5f);
@@ -134,8 +131,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000);
ASSERT(!pdfium::ContainsKey(m_CacheMap, charcode));
- CPDF_Type3Char* pCachedChar = pNewChar.release();
- m_CacheMap[charcode] = pCachedChar;
+ m_CacheMap[charcode] = std::move(pNewChar);
+ CPDF_Type3Char* pCachedChar = m_CacheMap[charcode].get();
if (pCachedChar->m_pForm->GetPageObjectList()->empty())
pCachedChar->m_pForm.reset();
return pCachedChar;
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_type3font.h ('k') | core/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698