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

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp

Issue 2275703002: Make indirect object holder private. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@indirect_naming
Patch Set: Created 4 years, 4 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
Index: core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
index bb29da5052e5abdfca4bc0f5df637ca0a30dad6e..d00b4a79618410f26a8c3d9932eab2978369c03e 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
@@ -20,20 +20,25 @@ CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {
pair.second->Destroy();
}
+CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(
+ uint32_t objnum) const {
+ auto it = m_IndirectObjs.find(objnum);
+ return it != m_IndirectObjs.end() ? it->second : nullptr;
+}
+
CPDF_Object* CPDF_IndirectObjectHolder::GetOrParseIndirectObject(
uint32_t objnum) {
if (objnum == 0)
return nullptr;
- auto it = m_IndirectObjs.find(objnum);
- if (it != m_IndirectObjs.end())
- return it->second->GetObjNum() != CPDF_Object::kInvalidObjNum ? it->second
- : nullptr;
+ CPDF_Object* pObj = GetIndirectObject(objnum);
+ if (pObj)
+ return pObj->GetObjNum() != CPDF_Object::kInvalidObjNum ? pObj : nullptr;
if (!m_pParser)
return nullptr;
- CPDF_Object* pObj = m_pParser->ParseIndirectObject(this, objnum);
+ pObj = m_pParser->ParseIndirectObject(this, objnum);
if (!pObj)
return nullptr;
@@ -62,13 +67,13 @@ bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(
if (!objnum || !pObj)
return false;
- auto it = m_IndirectObjs.find(objnum);
- if (it != m_IndirectObjs.end()) {
- if (pObj->GetGenNum() <= it->second->GetGenNum()) {
+ CPDF_Object* pOldObj = GetIndirectObject(objnum);
+ if (pOldObj) {
+ if (pObj->GetGenNum() <= pOldObj->GetGenNum()) {
pObj->Destroy();
return false;
}
- it->second->Destroy();
+ pOldObj->Destroy();
}
pObj->m_ObjNum = objnum;
m_IndirectObjs[objnum] = pObj;
@@ -77,11 +82,10 @@ bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(
}
void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) {
- auto it = m_IndirectObjs.find(objnum);
- if (it == m_IndirectObjs.end() ||
- it->second->GetObjNum() == CPDF_Object::kInvalidObjNum) {
+ CPDF_Object* pObj = GetIndirectObject(objnum);
+ if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
return;
- }
- it->second->Destroy();
- m_IndirectObjs.erase(it);
+
+ pObj->Destroy();
+ m_IndirectObjs.erase(objnum);
}
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_document.cpp ('k') | core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698