2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-05 08:02:11 +00:00

Improve efficiency of ResolveRecorder

Removing an element from a set with iterator is constant time, and
std::set specifies that other operations on the set do not invalidate
existing iterators.
This commit is contained in:
Jay Berkenbilt 2022-09-13 11:19:24 -04:00
parent 31b2cfbb79
commit c5f61fcbd3

View File

@ -1063,18 +1063,17 @@ class QPDF
public: public:
ResolveRecorder(QPDF* qpdf, QPDFObjGen const& og) : ResolveRecorder(QPDF* qpdf, QPDFObjGen const& og) :
qpdf(qpdf), qpdf(qpdf),
og(og) iter(qpdf->m->resolving.insert(og).first)
{ {
qpdf->m->resolving.insert(og);
} }
virtual ~ResolveRecorder() virtual ~ResolveRecorder()
{ {
this->qpdf->m->resolving.erase(og); this->qpdf->m->resolving.erase(iter);
} }
private: private:
QPDF* qpdf; QPDF* qpdf;
QPDFObjGen og; std::set<QPDFObjGen>::const_iterator iter;
}; };
friend class ResolveRecorder; friend class ResolveRecorder;