Commit 0e81ffa7b69a97ddbc04eb7b2bbc17433bfd3cb2
1 parent
9b080172
Use QPDFObjGen::set in NNTree
Showing
1 changed file
with
13 additions
and
20 deletions
libqpdf/NNTree.cc
| @@ -638,26 +638,21 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) | @@ -638,26 +638,21 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) | ||
| 638 | auto opath = this->path; | 638 | auto opath = this->path; |
| 639 | bool failed = false; | 639 | bool failed = false; |
| 640 | 640 | ||
| 641 | - std::set<QPDFObjGen> seen; | 641 | + QPDFObjGen::set seen; |
| 642 | for (auto i: this->path) { | 642 | for (auto i: this->path) { |
| 643 | - if (i.node.isIndirect()) { | ||
| 644 | - seen.insert(i.node.getObjGen()); | ||
| 645 | - } | 643 | + seen.add(i.node); |
| 646 | } | 644 | } |
| 647 | while (!failed) { | 645 | while (!failed) { |
| 648 | - if (node.isIndirect()) { | ||
| 649 | - auto og = node.getObjGen(); | ||
| 650 | - if (seen.count(og)) { | ||
| 651 | - QTC::TC("qpdf", "NNTree deepen: loop"); | ||
| 652 | - warn( | ||
| 653 | - impl.qpdf, | ||
| 654 | - node, | ||
| 655 | - "loop detected while traversing name/number tree"); | ||
| 656 | - failed = true; | ||
| 657 | - break; | ||
| 658 | - } | ||
| 659 | - seen.insert(og); | 646 | + if (!seen.add(node)) { |
| 647 | + QTC::TC("qpdf", "NNTree deepen: loop"); | ||
| 648 | + warn( | ||
| 649 | + impl.qpdf, | ||
| 650 | + node, | ||
| 651 | + "loop detected while traversing name/number tree"); | ||
| 652 | + failed = true; | ||
| 653 | + break; | ||
| 660 | } | 654 | } |
| 655 | + | ||
| 661 | if (!node.isDictionary()) { | 656 | if (!node.isDictionary()) { |
| 662 | QTC::TC("qpdf", "NNTree node is not a dictionary"); | 657 | QTC::TC("qpdf", "NNTree node is not a dictionary"); |
| 663 | warn( | 658 | warn( |
| @@ -928,17 +923,15 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found) | @@ -928,17 +923,15 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found) | ||
| 928 | } | 923 | } |
| 929 | } | 924 | } |
| 930 | 925 | ||
| 931 | - std::set<QPDFObjGen> seen; | 926 | + QPDFObjGen::set seen; |
| 932 | auto node = this->oh; | 927 | auto node = this->oh; |
| 933 | iterator result(*this); | 928 | iterator result(*this); |
| 934 | 929 | ||
| 935 | while (true) { | 930 | while (true) { |
| 936 | - auto og = node.getObjGen(); | ||
| 937 | - if (seen.count(og)) { | 931 | + if (!seen.add(node)) { |
| 938 | QTC::TC("qpdf", "NNTree loop in find"); | 932 | QTC::TC("qpdf", "NNTree loop in find"); |
| 939 | error(qpdf, node, "loop detected in find"); | 933 | error(qpdf, node, "loop detected in find"); |
| 940 | } | 934 | } |
| 941 | - seen.insert(og); | ||
| 942 | 935 | ||
| 943 | auto kids = node.getKey("/Kids"); | 936 | auto kids = node.getKey("/Kids"); |
| 944 | int nkids = kids.isArray() ? kids.getArrayNItems() : 0; | 937 | int nkids = kids.isArray() ? kids.getArrayNItems() : 0; |