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

Unified 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, 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index eab0ee595b3a0a5df0e88d4f3358604f778d7e7e..0e9cd3b55d0e3addcaa98c6b7fa95e7b36d08f0c 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -41,12 +41,22 @@ const FX_STRSIZE kMaxStringLength = 32767;
} // namespace
-CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize) {
- m_pBuf = pData;
- m_Size = dwSize;
- m_Pos = 0;
- m_pLastObj = nullptr;
-}
+CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize)
+ : m_pBuf(pData),
+ m_Size(dwSize),
+ m_Pos(0),
+ m_pLastObj(nullptr),
+ m_pPool(nullptr) {}
+
+CPDF_StreamParser::CPDF_StreamParser(
+ const uint8_t* pData,
+ uint32_t dwSize,
+ const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+ : m_pBuf(pData),
+ m_Size(dwSize),
+ m_Pos(0),
+ m_pLastObj(nullptr),
+ m_pPool(pPool) {}
CPDF_StreamParser::~CPDF_StreamParser() {
if (m_pLastObj) {
@@ -336,18 +346,21 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
int first_char = m_WordBuffer[0];
if (first_char == '/') {
- return new CPDF_Name(
- PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
+ CFX_ByteString name =
+ PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
+ return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name);
}
- if (first_char == '(')
- return new CPDF_String(ReadString(), FALSE);
+ if (first_char == '(') {
+ CFX_ByteString str = ReadString();
+ return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, FALSE);
+ }
if (first_char == '<') {
if (m_WordSize == 1)
return new CPDF_String(ReadHexString(), TRUE);
- CPDF_Dictionary* pDict = new CPDF_Dictionary;
+ CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
while (1) {
GetNextWord(bIsNumber);
if (m_WordSize == 2 && m_WordBuffer[0] == '>')
« 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