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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1520643002: Replace several more CFX_MapPtrToPtr with std::set or std::map (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years 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/include/fxge/fx_font.h ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_text.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 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/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include "core/include/fxcrt/fx_string.h" 9 #include "core/include/fxcrt/fx_string.h"
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 CPDF_Object* CPDF_Object::GetDirect() const { 221 CPDF_Object* CPDF_Object::GetDirect() const {
222 const CPDF_Reference* pRef = AsReference(); 222 const CPDF_Reference* pRef = AsReference();
223 if (!pRef) 223 if (!pRef)
224 return const_cast<CPDF_Object*>(this); 224 return const_cast<CPDF_Object*>(this);
225 if (!pRef->m_pObjList) 225 if (!pRef->m_pObjList)
226 return nullptr; 226 return nullptr;
227 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum()); 227 return pRef->m_pObjList->GetIndirectObject(pRef->GetRefObjNum());
228 } 228 }
229 CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const { 229 CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const {
230 CFX_MapPtrToPtr visited; 230 std::set<FX_DWORD> visited;
231 return CloneInternal(bDirect, &visited); 231 return CloneInternal(bDirect, &visited);
232 } 232 }
233 CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, 233 CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
234 CFX_MapPtrToPtr* visited) const { 234 std::set<FX_DWORD>* visited) const {
235 switch (m_Type) { 235 switch (m_Type) {
236 case PDFOBJ_BOOLEAN: 236 case PDFOBJ_BOOLEAN:
237 return new CPDF_Boolean(AsBoolean()->m_bValue); 237 return new CPDF_Boolean(AsBoolean()->m_bValue);
238 case PDFOBJ_NUMBER: { 238 case PDFOBJ_NUMBER: {
239 const CPDF_Number* pThis = AsNumber(); 239 const CPDF_Number* pThis = AsNumber();
240 return new CPDF_Number(pThis->m_bInteger ? pThis->m_Integer 240 return new CPDF_Number(pThis->m_bInteger ? pThis->m_Integer
241 : pThis->m_Float); 241 : pThis->m_Float);
242 } 242 }
243 case PDFOBJ_STRING: { 243 case PDFOBJ_STRING: {
244 const CPDF_String* pString = AsString(); 244 const CPDF_String* pString = AsString();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 FX_DWORD streamSize = acc.GetSize(); 278 FX_DWORD streamSize = acc.GetSize();
279 CPDF_Dictionary* pDict = pThis->GetDict(); 279 CPDF_Dictionary* pDict = pThis->GetDict();
280 if (pDict) { 280 if (pDict) {
281 pDict = ToDictionary(pDict->CloneInternal(bDirect, visited)); 281 pDict = ToDictionary(pDict->CloneInternal(bDirect, visited));
282 } 282 }
283 return new CPDF_Stream(acc.DetachData(), streamSize, pDict); 283 return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
284 } 284 }
285 case PDFOBJ_REFERENCE: { 285 case PDFOBJ_REFERENCE: {
286 const CPDF_Reference* pRef = AsReference(); 286 const CPDF_Reference* pRef = AsReference();
287 FX_DWORD obj_num = pRef->GetRefObjNum(); 287 FX_DWORD obj_num = pRef->GetRefObjNum();
288 if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) { 288 if (bDirect && visited->find(obj_num) == visited->end()) {
Lei Zhang 2015/12/10 22:28:03 Someday I'm going to sneak ContainsKey() into PDFi
289 visited->SetAt((void*)(uintptr_t)obj_num, (void*)1); 289 visited->insert(obj_num);
290 if (!pRef->GetDirect()) 290 if (!pRef->GetDirect())
291 return nullptr; 291 return nullptr;
292 292
293 return pRef->GetDirect()->CloneInternal(TRUE, visited); 293 return pRef->GetDirect()->CloneInternal(TRUE, visited);
294 } 294 }
295 return new CPDF_Reference(pRef->m_pObjList, obj_num); 295 return new CPDF_Reference(pRef->m_pObjList, obj_num);
296 } 296 }
297 } 297 }
298 return NULL; 298 return NULL;
299 } 299 }
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 } 1172 }
1173 pObj->m_ObjNum = objnum; 1173 pObj->m_ObjNum = objnum;
1174 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); 1174 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj);
1175 if (m_LastObjNum < objnum) { 1175 if (m_LastObjNum < objnum) {
1176 m_LastObjNum = objnum; 1176 m_LastObjNum = objnum;
1177 } 1177 }
1178 } 1178 }
1179 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { 1179 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const {
1180 return m_LastObjNum; 1180 return m_LastObjNum;
1181 } 1181 }
OLDNEW
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698