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

Side by Side Diff: core/fpdfapi/page/cpdf_streamparser.cpp

Issue 2509123002: Make CPDF_Object subclass constructors intern strings (Closed)
Patch Set: Nits 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/page/pageint.h" 7 #include "core/fpdfapi/page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 if (bIsNumber) { 330 if (bIsNumber) {
331 m_WordBuffer[m_WordSize] = 0; 331 m_WordBuffer[m_WordSize] = 0;
332 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize)); 332 return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize));
333 } 333 }
334 334
335 int first_char = m_WordBuffer[0]; 335 int first_char = m_WordBuffer[0];
336 if (first_char == '/') { 336 if (first_char == '/') {
337 CFX_ByteString name = 337 CFX_ByteString name =
338 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 338 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
339 return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name); 339 return new CPDF_Name(m_pPool, name);
340 } 340 }
341 341
342 if (first_char == '(') { 342 if (first_char == '(') {
343 CFX_ByteString str = ReadString(); 343 CFX_ByteString str = ReadString();
344 return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, false); 344 return new CPDF_String(m_pPool, str, false);
345 } 345 }
346 346
347 if (first_char == '<') { 347 if (first_char == '<') {
348 if (m_WordSize == 1) 348 if (m_WordSize == 1)
349 return new CPDF_String(ReadHexString(), true); 349 return new CPDF_String(m_pPool, ReadHexString(), true);
350 350
351 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); 351 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
352 while (1) { 352 while (1) {
353 GetNextWord(bIsNumber); 353 GetNextWord(bIsNumber);
354 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 354 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
355 break; 355 break;
356 356
357 if (!m_WordSize || m_WordBuffer[0] != '/') { 357 if (!m_WordSize || m_WordBuffer[0] != '/') {
358 delete pDict; 358 delete pDict;
359 return nullptr; 359 return nullptr;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 617
618 if (buf.GetLength() > kMaxStringLength) 618 if (buf.GetLength() > kMaxStringLength)
619 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); 619 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength);
620 620
621 return buf.MakeString(); 621 return buf.MakeString();
622 } 622 }
623 623
624 bool CPDF_StreamParser::PositionIsInBounds() const { 624 bool CPDF_StreamParser::PositionIsInBounds() const {
625 return m_Pos < m_Size; 625 return m_Pos < m_Size;
626 } 626 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_streamcontentparser.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698