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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile Created 4 years, 2 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_page/fpdf_page_parser.cpp ('k') | core/fpdfapi/fpdf_page/pageint.h » ('j') | 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_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 23 matching lines...) Expand all
34 #include "core/fxge/include/cfx_renderdevice.h" 34 #include "core/fxge/include/cfx_renderdevice.h"
35 35
36 namespace { 36 namespace {
37 37
38 const uint32_t kMaxNestedArrayLevel = 512; 38 const uint32_t kMaxNestedArrayLevel = 512;
39 const uint32_t kMaxWordBuffer = 256; 39 const uint32_t kMaxWordBuffer = 256;
40 const FX_STRSIZE kMaxStringLength = 32767; 40 const FX_STRSIZE kMaxStringLength = 32767;
41 41
42 } // namespace 42 } // namespace
43 43
44 CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize) { 44 CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize)
45 m_pBuf = pData; 45 : m_pBuf(pData),
46 m_Size = dwSize; 46 m_Size(dwSize),
47 m_Pos = 0; 47 m_Pos(0),
48 m_pLastObj = nullptr; 48 m_pLastObj(nullptr),
49 } 49 m_pPool(nullptr) {}
50
51 CPDF_StreamParser::CPDF_StreamParser(
52 const uint8_t* pData,
53 uint32_t dwSize,
54 const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
55 : m_pBuf(pData),
56 m_Size(dwSize),
57 m_Pos(0),
58 m_pLastObj(nullptr),
59 m_pPool(pPool) {}
50 60
51 CPDF_StreamParser::~CPDF_StreamParser() { 61 CPDF_StreamParser::~CPDF_StreamParser() {
52 if (m_pLastObj) { 62 if (m_pLastObj) {
53 m_pLastObj->Release(); 63 m_pLastObj->Release();
54 } 64 }
55 } 65 }
56 66
57 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder, 67 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
58 uint8_t*& dest_buf, 68 uint8_t*& dest_buf,
59 uint32_t& dest_size) { 69 uint32_t& dest_size) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (!m_WordSize) 339 if (!m_WordSize)
330 return nullptr; 340 return nullptr;
331 341
332 if (bIsNumber) { 342 if (bIsNumber) {
333 m_WordBuffer[m_WordSize] = 0; 343 m_WordBuffer[m_WordSize] = 0;
334 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize)); 344 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize));
335 } 345 }
336 346
337 int first_char = m_WordBuffer[0]; 347 int first_char = m_WordBuffer[0];
338 if (first_char == '/') { 348 if (first_char == '/') {
339 return new CPDF_Name( 349 CFX_ByteString name =
340 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); 350 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
351 return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name);
341 } 352 }
342 353
343 if (first_char == '(') 354 if (first_char == '(') {
344 return new CPDF_String(ReadString(), FALSE); 355 CFX_ByteString str = ReadString();
356 return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, FALSE);
357 }
345 358
346 if (first_char == '<') { 359 if (first_char == '<') {
347 if (m_WordSize == 1) 360 if (m_WordSize == 1)
348 return new CPDF_String(ReadHexString(), TRUE); 361 return new CPDF_String(ReadHexString(), TRUE);
349 362
350 CPDF_Dictionary* pDict = new CPDF_Dictionary; 363 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
351 while (1) { 364 while (1) {
352 GetNextWord(bIsNumber); 365 GetNextWord(bIsNumber);
353 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 366 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
354 break; 367 break;
355 368
356 if (!m_WordSize || m_WordBuffer[0] != '/') { 369 if (!m_WordSize || m_WordBuffer[0] != '/') {
357 pDict->Release(); 370 pDict->Release();
358 return nullptr; 371 return nullptr;
359 } 372 }
360 373
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 830 }
818 m_Status = Done; 831 m_Status = Done;
819 return; 832 return;
820 } 833 }
821 steps++; 834 steps++;
822 if (pPause && pPause->NeedToPauseNow()) { 835 if (pPause && pPause->NeedToPauseNow()) {
823 break; 836 break;
824 } 837 }
825 } 838 }
826 } 839 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_parser.cpp ('k') | core/fpdfapi/fpdf_page/pageint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698