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

Side by Side Diff: core/fpdfapi/fpdf_font/fpdf_font_cid.cpp

Issue 1889003002: Avoid string allocs for CMap_GetString() return value. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Remove some calls where the result is not used. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_font/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 }; 183 };
184 184
185 CIDSet CIDSetFromSizeT(size_t index) { 185 CIDSet CIDSetFromSizeT(size_t index) {
186 if (index >= CIDSET_NUM_SETS) { 186 if (index >= CIDSET_NUM_SETS) {
187 NOTREACHED(); 187 NOTREACHED();
188 return CIDSET_UNKNOWN; 188 return CIDSET_UNKNOWN;
189 } 189 }
190 return static_cast<CIDSet>(index); 190 return static_cast<CIDSet>(index);
191 } 191 }
192 192
193 CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { 193 CFX_ByteStringC CMap_GetString(const CFX_ByteStringC& word) {
194 return word.Mid(1, word.GetLength() - 2); 194 return word.Mid(1, word.GetLength() - 2);
195 } 195 }
196 196
197 int CompareDWORD(const void* data1, const void* data2) { 197 int CompareDWORD(const void* data1, const void* data2) {
198 return (*(uint32_t*)data1) - (*(uint32_t*)data2); 198 return (*(uint32_t*)data1) - (*(uint32_t*)data2);
199 } 199 }
200 200
201 int CompareCID(const void* key, const void* element) { 201 int CompareCID(const void* key, const void* element) {
202 if ((*(uint32_t*)key) < (*(uint32_t*)element)) { 202 if ((*(uint32_t*)key) < (*(uint32_t*)element)) {
203 return -1; 203 return -1;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 m_pCMap->m_pMapping[code] = (uint16_t)(StartCID + code - StartCode); 400 m_pCMap->m_pMapping[code] = (uint16_t)(StartCID + code - StartCode);
401 } 401 }
402 } else { 402 } else {
403 uint32_t buf[2]; 403 uint32_t buf[2];
404 buf[0] = StartCode; 404 buf[0] = StartCode;
405 buf[1] = ((EndCode - StartCode) << 16) + StartCID; 405 buf[1] = ((EndCode - StartCode) << 16) + StartCID;
406 m_AddMaps.AppendBlock(buf, sizeof buf); 406 m_AddMaps.AppendBlock(buf, sizeof buf);
407 } 407 }
408 m_CodeSeq = 0; 408 m_CodeSeq = 0;
409 } else if (m_Status == 3) { 409 } else if (m_Status == 3) {
410 CMap_GetString(word);
411 m_Status = 0; 410 m_Status = 0;
412 } else if (m_Status == 4) { 411 } else if (m_Status == 4) {
413 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word)); 412 m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word));
414 m_Status = 0; 413 m_Status = 0;
415 } else if (m_Status == 5) { 414 } else if (m_Status == 5) {
416 CMap_GetCode(word);
417 m_Status = 0; 415 m_Status = 0;
418 } else if (m_Status == 6) { 416 } else if (m_Status == 6) {
419 m_pCMap->m_bVertical = CMap_GetCode(word); 417 m_pCMap->m_bVertical = CMap_GetCode(word);
420 m_Status = 0; 418 m_Status = 0;
421 } else if (m_Status == 7) { 419 } else if (m_Status == 7) {
422 if (word == "endcodespacerange") { 420 if (word == "endcodespacerange") {
423 int nSegs = m_CodeRanges.GetSize(); 421 int nSegs = m_CodeRanges.GetSize();
424 if (nSegs > 1) { 422 if (nSegs > 1) {
425 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; 423 m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes;
426 m_pCMap->m_nCodeRanges = nSegs; 424 m_pCMap->m_nCodeRanges = nSegs;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 return 0; 779 return 0;
782 } 780 }
783 781
784 void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, 782 void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr,
785 CIDSet charset, 783 CIDSet charset,
786 FX_BOOL bPromptCJK) { 784 FX_BOOL bPromptCJK) {
787 m_Charset = charset; 785 m_Charset = charset;
788 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); 786 FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount);
789 } 787 }
790 788
791 CIDSet CharsetFromOrdering(const CFX_ByteString& ordering) { 789 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) {
792 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { 790 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
793 if (ordering == CFX_ByteStringC(g_CharsetNames[charset])) 791 if (ordering == g_CharsetNames[charset])
794 return CIDSetFromSizeT(charset); 792 return CIDSetFromSizeT(charset);
795 } 793 }
796 return CIDSET_UNKNOWN; 794 return CIDSET_UNKNOWN;
797 } 795 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698