diff options
author | tsepez <tsepez@chromium.org> | 2016-04-14 18:17:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-14 18:17:03 -0700 |
commit | b1c80fb8b843a2a345b2cd6005e591dc731355f4 (patch) | |
tree | 296e923c6a13f5321bcf52f83c69346c41020dbd /core/fpdfapi/fpdf_font | |
parent | 80b103bf53ee1249823e6bb3bed9cb2bc15ca67a (diff) | |
download | pdfium-b1c80fb8b843a2a345b2cd6005e591dc731355f4.tar.xz |
Avoid string allocs for CMap_GetString() return value.
StringC's are all that's needed here. Also CMap_GetString()
and GetCode() are side-effect free, so remove calls where
the value is not used.
Review URL: https://codereview.chromium.org/1889003002
Diffstat (limited to 'core/fpdfapi/fpdf_font')
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_cidfont.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/font_int.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 8 |
3 files changed, 6 insertions, 7 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index 034f6f6ece..6089e75ec2 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -401,7 +401,8 @@ FX_BOOL CPDF_CIDFont::Load() { if (m_Charset == CIDSET_UNKNOWN) { CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictBy("CIDSystemInfo"); if (pCIDInfo) { - m_Charset = CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering")); + m_Charset = + CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering").AsStringC()); } } if (m_Charset != CIDSET_UNKNOWN) diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h index fc69b0cbd9..792377ebf0 100644 --- a/core/fpdfapi/fpdf_font/font_int.h +++ b/core/fpdfapi/fpdf_font/font_int.h @@ -22,7 +22,7 @@ typedef void* FXFT_Library; short TT2PDF(int m, FXFT_Face face); FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id); -CIDSet CharsetFromOrdering(const CFX_ByteString& ordering); +CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering); class CPDF_CMapManager { public: diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index f84fa9f2f9..d5fe4dfd92 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -190,7 +190,7 @@ CIDSet CIDSetFromSizeT(size_t index) { return static_cast<CIDSet>(index); } -CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { +CFX_ByteStringC CMap_GetString(const CFX_ByteStringC& word) { return word.Mid(1, word.GetLength() - 2); } @@ -407,13 +407,11 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } m_CodeSeq = 0; } else if (m_Status == 3) { - CMap_GetString(word); m_Status = 0; } else if (m_Status == 4) { m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); m_Status = 0; } else if (m_Status == 5) { - CMap_GetCode(word); m_Status = 0; } else if (m_Status == 6) { m_pCMap->m_bVertical = CMap_GetCode(word); @@ -788,9 +786,9 @@ void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); } -CIDSet CharsetFromOrdering(const CFX_ByteString& ordering) { +CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { - if (ordering == CFX_ByteStringC(g_CharsetNames[charset])) + if (ordering == g_CharsetNames[charset]) return CIDSetFromSizeT(charset); } return CIDSET_UNKNOWN; |