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