Commit 55abecc42dc44d1b93337afe9628fea029a85696
1 parent
0e81ffa7
Use QPDFObjGen::set in QPDFOutlineDocumentHelper
Showing
2 changed files
with
7 additions
and
22 deletions
include/qpdf/QPDFOutlineDocumentHelper.hh
| ... | ... | @@ -22,13 +22,13 @@ |
| 22 | 22 | #ifndef QPDFOUTLINEDOCUMENTHELPER_HH |
| 23 | 23 | #define QPDFOUTLINEDOCUMENTHELPER_HH |
| 24 | 24 | |
| 25 | +#include <qpdf/QPDF.hh> | |
| 25 | 26 | #include <qpdf/QPDFDocumentHelper.hh> |
| 26 | 27 | #include <qpdf/QPDFNameTreeObjectHelper.hh> |
| 28 | +#include <qpdf/QPDFObjGen.hh> | |
| 27 | 29 | #include <qpdf/QPDFOutlineObjectHelper.hh> |
| 28 | 30 | |
| 29 | -#include <qpdf/QPDF.hh> | |
| 30 | 31 | #include <map> |
| 31 | -#include <set> | |
| 32 | 32 | #include <vector> |
| 33 | 33 | |
| 34 | 34 | #include <qpdf/DLL.h> |
| ... | ... | @@ -69,16 +69,16 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper |
| 69 | 69 | { |
| 70 | 70 | friend class QPDFOutlineObjectHelper; |
| 71 | 71 | |
| 72 | + // ABI: remove QPDF_DLL and pass og by value. | |
| 72 | 73 | QPDF_DLL |
| 73 | 74 | static bool |
| 74 | 75 | checkSeen(QPDFOutlineDocumentHelper& dh, QPDFObjGen const& og) |
| 75 | 76 | { |
| 76 | - return dh.checkSeen(og); | |
| 77 | + return !dh.m->seen.add(og); | |
| 77 | 78 | } |
| 78 | 79 | }; |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | - bool checkSeen(QPDFObjGen const& og); | |
| 82 | 82 | void initializeByPage(); |
| 83 | 83 | |
| 84 | 84 | class Members |
| ... | ... | @@ -94,7 +94,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper |
| 94 | 94 | Members(Members const&) = delete; |
| 95 | 95 | |
| 96 | 96 | std::vector<QPDFOutlineObjectHelper> outlines; |
| 97 | - std::set<QPDFObjGen> seen; | |
| 97 | + QPDFObjGen::set seen; | |
| 98 | 98 | QPDFObjectHandle dest_dict; |
| 99 | 99 | std::shared_ptr<QPDFNameTreeObjectHelper> names_dest; |
| 100 | 100 | std::map<QPDFObjGen, std::vector<QPDFOutlineObjectHelper>> by_page; | ... | ... |
libqpdf/QPDFOutlineDocumentHelper.cc
| ... | ... | @@ -15,13 +15,8 @@ QPDFOutlineDocumentHelper::QPDFOutlineDocumentHelper(QPDF& qpdf) : |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | QPDFObjectHandle cur = outlines.getKey("/First"); |
| 18 | - std::set<QPDFObjGen> seen; | |
| 19 | - while (!cur.isNull()) { | |
| 20 | - auto og = cur.getObjGen(); | |
| 21 | - if (seen.count(og)) { | |
| 22 | - break; | |
| 23 | - } | |
| 24 | - seen.insert(og); | |
| 18 | + QPDFObjGen::set seen; | |
| 19 | + while (!cur.isNull() && seen.add(cur)) { | |
| 25 | 20 | this->m->outlines.push_back( |
| 26 | 21 | QPDFOutlineObjectHelper::Accessor::create(cur, *this, 1)); |
| 27 | 22 | cur = cur.getKey("/Next"); |
| ... | ... | @@ -104,13 +99,3 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) |
| 104 | 99 | } |
| 105 | 100 | return result; |
| 106 | 101 | } |
| 107 | - | |
| 108 | -bool | |
| 109 | -QPDFOutlineDocumentHelper::checkSeen(QPDFObjGen const& og) | |
| 110 | -{ | |
| 111 | - if (this->m->seen.count(og) > 0) { | |
| 112 | - return true; | |
| 113 | - } | |
| 114 | - this->m->seen.insert(og); | |
| 115 | - return false; | |
| 116 | -} | ... | ... |