Commit ae2d623929c280f1d2411787bf4e41d5d91a4f3a

Authored by m-holger
1 parent 8fbef470

Use QPDFObjGen::set in QPDF::updateObjectMaps

include/qpdf/QPDF.hh
@@ -1645,7 +1645,7 @@ class QPDF @@ -1645,7 +1645,7 @@ class QPDF
1645 ObjUser const& ou, 1645 ObjUser const& ou,
1646 QPDFObjectHandle oh, 1646 QPDFObjectHandle oh,
1647 std::function<int(QPDFObjectHandle&)> skip_stream_parameters, 1647 std::function<int(QPDFObjectHandle&)> skip_stream_parameters,
1648 - std::set<QPDFObjGen>& visited, 1648 + QPDFObjGen::set& visited,
1649 bool top); 1649 bool top);
1650 void filterCompressedObjects(std::map<int, int> const& object_stream_data); 1650 void filterCompressedObjects(std::map<int, int> const& object_stream_data);
1651 1651
libqpdf/QPDF_optimization.cc
@@ -284,7 +284,7 @@ QPDF::updateObjectMaps( @@ -284,7 +284,7 @@ QPDF::updateObjectMaps(
284 QPDFObjectHandle oh, 284 QPDFObjectHandle oh,
285 std::function<int(QPDFObjectHandle&)> skip_stream_parameters) 285 std::function<int(QPDFObjectHandle&)> skip_stream_parameters)
286 { 286 {
287 - std::set<QPDFObjGen> visited; 287 + QPDFObjGen::set visited;
288 updateObjectMapsInternal(ou, oh, skip_stream_parameters, visited, true); 288 updateObjectMapsInternal(ou, oh, skip_stream_parameters, visited, true);
289 } 289 }
290 290
@@ -293,7 +293,7 @@ QPDF::updateObjectMapsInternal( @@ -293,7 +293,7 @@ QPDF::updateObjectMapsInternal(
293 ObjUser const& ou, 293 ObjUser const& ou,
294 QPDFObjectHandle oh, 294 QPDFObjectHandle oh,
295 std::function<int(QPDFObjectHandle&)> skip_stream_parameters, 295 std::function<int(QPDFObjectHandle&)> skip_stream_parameters,
296 - std::set<QPDFObjGen>& visited, 296 + QPDFObjGen::set& visited,
297 bool top) 297 bool top)
298 { 298 {
299 // Traverse the object tree from this point taking care to avoid 299 // Traverse the object tree from this point taking care to avoid
@@ -310,13 +310,12 @@ QPDF::updateObjectMapsInternal( @@ -310,13 +310,12 @@ QPDF::updateObjectMapsInternal(
310 310
311 if (oh.isIndirect()) { 311 if (oh.isIndirect()) {
312 QPDFObjGen og(oh.getObjGen()); 312 QPDFObjGen og(oh.getObjGen());
313 - if (visited.count(og)) { 313 + if (!visited.add(og)) {
314 QTC::TC("qpdf", "QPDF opt loop detected"); 314 QTC::TC("qpdf", "QPDF opt loop detected");
315 return; 315 return;
316 } 316 }
317 this->m->obj_user_to_objects[ou].insert(og); 317 this->m->obj_user_to_objects[ou].insert(og);
318 this->m->object_to_obj_users[og].insert(ou); 318 this->m->object_to_obj_users[og].insert(ou);
319 - visited.insert(og);  
320 } 319 }
321 320
322 if (oh.isArray()) { 321 if (oh.isArray()) {