aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-01-25 14:05:43 +0100
committerJay Berkenbilt <ejb@ql.org>2021-01-26 15:12:23 +0100
commit8ed3e8c79b5cbccfeccee865e555b68025ee2c1f (patch)
tree159063cdb1773605254e0436365d4eeb137282ff /libqpdf/qpdf
parente7e20772ed29f3eb9756b31fe0bd9bc29a445891 (diff)
downloadqpdf-8ed3e8c79b5cbccfeccee865e555b68025ee2c1f.tar.zst
NNTree: rework iterators to be more memory efficient
Keep a std::pair internal to the iterators so that operator* can return a reference and operator-> can work, and each can work without copying pairs of objects around.
Diffstat (limited to 'libqpdf/qpdf')
-rw-r--r--libqpdf/qpdf/NNTree.hh7
1 files changed, 4 insertions, 3 deletions
diff --git a/libqpdf/qpdf/NNTree.hh b/libqpdf/qpdf/NNTree.hh
index e8360df1..4a843a73 100644
--- a/libqpdf/qpdf/NNTree.hh
+++ b/libqpdf/qpdf/NNTree.hh
@@ -6,6 +6,7 @@
#include <iterator>
#include <list>
+#include <memory>
class NNTreeDetails
{
@@ -18,9 +19,6 @@ class NNTreeDetails
class NNTreeImpl;
class NNTreeIterator: public std::iterator<
std::bidirectional_iterator_tag,
- std::pair<QPDFObjectHandle, QPDFObjectHandle>,
- void,
- std::pair<QPDFObjectHandle, QPDFObjectHandle>*,
std::pair<QPDFObjectHandle, QPDFObjectHandle>>
{
friend class NNTreeImpl;
@@ -41,6 +39,7 @@ class NNTreeIterator: public std::iterator<
return t;
}
reference operator*();
+ pointer operator->();
bool operator==(NNTreeIterator const& other) const;
bool operator!=(NNTreeIterator const& other) const
{
@@ -63,6 +62,7 @@ class NNTreeIterator: public std::iterator<
// ABI: for qpdf 11, make qpdf a reference
NNTreeIterator(NNTreeImpl& impl);
+ void updateIValue(bool allow_invalid = true);
bool deepen(QPDFObjectHandle node, bool first, bool allow_empty);
void setItemNumber(QPDFObjectHandle const& node, int);
void addPathElement(QPDFObjectHandle const& node, int kid_number);
@@ -79,6 +79,7 @@ class NNTreeIterator: public std::iterator<
std::list<PathElement> path;
QPDFObjectHandle node;
int item_number;
+ value_type ivalue;
};
class NNTreeImpl