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

Unified Diff: core/fpdfapi/font/cpdf_fontencoding.cpp

Issue 2520133002: Remove some WrapUnique() calls by returing unique_ptrs (Closed)
Patch Set: rebase Created 4 years, 1 month 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/font/cpdf_fontencoding.h ('k') | core/fpdfapi/page/cpdf_docpagedata.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/font/cpdf_fontencoding.cpp
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index df21267e1da56eea466286c281f5522d318d9016..88b2c8d6a53dab86dae535634249ef172c943737 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -1672,7 +1672,8 @@ bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const {
0;
}
-CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
+std::unique_ptr<CPDF_Object> CPDF_FontEncoding::Realize(
+ CFX_WeakPtr<CFX_ByteStringPool> pPool) {
int predefined = 0;
for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
cs++) {
@@ -1690,15 +1691,13 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
}
}
if (predefined) {
- if (predefined == PDFFONT_ENCODING_WINANSI) {
- return new CPDF_Name(pPool, "WinAnsiEncoding");
- }
- if (predefined == PDFFONT_ENCODING_MACROMAN) {
- return new CPDF_Name(pPool, "MacRomanEncoding");
- }
- if (predefined == PDFFONT_ENCODING_MACEXPERT) {
- return new CPDF_Name(pPool, "MacExpertEncoding");
- }
+ if (predefined == PDFFONT_ENCODING_WINANSI)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "WinAnsiEncoding");
+ if (predefined == PDFFONT_ENCODING_MACROMAN)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "MacRomanEncoding");
+ if (predefined == PDFFONT_ENCODING_MACEXPERT)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "MacExpertEncoding");
+
return nullptr;
}
const uint16_t* pStandard =
@@ -1712,10 +1711,10 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
pDiff->AddNew<CPDF_Name>(PDF_AdobeNameFromUnicode(m_Unicodes[i]));
}
- CPDF_Dictionary* pDict = new CPDF_Dictionary(pPool);
+ auto pDict = pdfium::MakeUnique<CPDF_Dictionary>(pPool);
pDict->SetNewFor<CPDF_Name>("BaseEncoding", "WinAnsiEncoding");
pDict->SetFor("Differences", std::move(pDiff));
- return pDict;
+ return std::move(pDict);
}
uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) {
« no previous file with comments | « core/fpdfapi/font/cpdf_fontencoding.h ('k') | core/fpdfapi/page/cpdf_docpagedata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698