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

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

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: Remove default ctor Created 4 years, 3 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
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(const uint8_t* pData,
52 uint32_t dwSize,
53 CFX_ByteStringPool* pPool)
54 : m_pBuf(pData),
55 m_Size(dwSize),
56 m_Pos(0),
57 m_pLastObj(nullptr),
58 m_pPool(pPool) {}
50 59
51 CPDF_StreamParser::~CPDF_StreamParser() { 60 CPDF_StreamParser::~CPDF_StreamParser() {
52 if (m_pLastObj) { 61 if (m_pLastObj) {
53 m_pLastObj->Release(); 62 m_pLastObj->Release();
54 } 63 }
55 } 64 }
56 65
57 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder, 66 uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
58 uint8_t*& dest_buf, 67 uint8_t*& dest_buf,
59 uint32_t& dest_size) { 68 uint32_t& dest_size) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (!m_WordSize) 338 if (!m_WordSize)
330 return nullptr; 339 return nullptr;
331 340
332 if (bIsNumber) { 341 if (bIsNumber) {
333 m_WordBuffer[m_WordSize] = 0; 342 m_WordBuffer[m_WordSize] = 0;
334 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize)); 343 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize));
335 } 344 }
336 345
337 int first_char = m_WordBuffer[0]; 346 int first_char = m_WordBuffer[0];
338 if (first_char == '/') { 347 if (first_char == '/') {
339 return new CPDF_Name( 348 CFX_ByteString name =
340 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); 349 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
350 return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name);
341 } 351 }
342 352
343 if (first_char == '(') 353 if (first_char == '(') {
344 return new CPDF_String(ReadString(), FALSE); 354 CFX_ByteString str = ReadString();
355 return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, FALSE);
356 }
345 357
346 if (first_char == '<') { 358 if (first_char == '<') {
347 if (m_WordSize == 1) 359 if (m_WordSize == 1)
348 return new CPDF_String(ReadHexString(), TRUE); 360 return new CPDF_String(ReadHexString(), TRUE);
349 361
350 CPDF_Dictionary* pDict = new CPDF_Dictionary; 362 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
351 while (1) { 363 while (1) {
352 GetNextWord(bIsNumber); 364 GetNextWord(bIsNumber);
353 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 365 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
354 break; 366 break;
355 367
356 if (!m_WordSize || m_WordBuffer[0] != '/') { 368 if (!m_WordSize || m_WordBuffer[0] != '/') {
357 pDict->Release(); 369 pDict->Release();
358 return nullptr; 370 return nullptr;
359 } 371 }
360 372
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 829 }
818 m_Status = Done; 830 m_Status = Done;
819 return; 831 return;
820 } 832 }
821 steps++; 833 steps++;
822 if (pPause && pPause->NeedToPauseNow()) { 834 if (pPause && pPause->NeedToPauseNow()) {
823 break; 835 break;
824 } 836 }
825 } 837 }
826 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698