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

Unified Diff: core/fpdfapi/parser/cpdf_string.cpp

Issue 2509123002: Make CPDF_Object subclass constructors intern strings (Closed)
Patch Set: finish 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 side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/parser/cpdf_string.cpp
diff --git a/core/fpdfapi/parser/cpdf_string.cpp b/core/fpdfapi/parser/cpdf_string.cpp
index 2116c200fe880fc8baf0b3cf43171ec82e41c4fc..082b07346c89223dbd79f11abf148fd29a30f12e 100644
--- a/core/fpdfapi/parser/cpdf_string.cpp
+++ b/core/fpdfapi/parser/cpdf_string.cpp
@@ -11,8 +11,13 @@
CPDF_String::CPDF_String() : m_bHex(false) {}
-CPDF_String::CPDF_String(const CFX_ByteString& str, bool bHex)
- : m_String(str), m_bHex(bHex) {}
+CPDF_String::CPDF_String(CFX_WeakPtr<CFX_ByteStringPool> pPool,
+ const CFX_ByteString& str,
+ bool bHex)
+ : m_String(str), m_bHex(bHex) {
+ if (pPool)
+ m_String = pPool->Intern(m_String);
+}
CPDF_String::CPDF_String(const CFX_WideString& str) : m_bHex(false) {
m_String = PDF_EncodeText(str);
@@ -25,7 +30,10 @@ CPDF_Object::Type CPDF_String::GetType() const {
}
std::unique_ptr<CPDF_Object> CPDF_String::Clone() const {
- return pdfium::MakeUnique<CPDF_String>(m_String, m_bHex);
+ auto pRet = pdfium::MakeUnique<CPDF_String>();
+ pRet->m_String = m_String;
+ pRet->m_bHex = m_bHex;
+ return pRet;
Lei Zhang 2016/11/17 01:05:06 Old Android toolchain probably want a std::move()
Tom Sepez 2016/11/17 01:13:48 Done.
}
CFX_ByteString CPDF_String::GetString() const {

Powered by Google App Engine
This is Rietveld 408576698