2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-31 14:01:59 +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:
ResolveRecorder(QPDF* qpdf, QPDFObjGen const& og) :
qpdf(qpdf),
og(og)
iter(qpdf->m->resolving.insert(og).first)
{
qpdf->m->resolving.insert(og);
}
virtual ~ResolveRecorder()
{
this->qpdf->m->resolving.erase(og);
this->qpdf->m->resolving.erase(iter);
}
private:
QPDF* qpdf;
QPDFObjGen og;
std::set<QPDFObjGen>::const_iterator iter;
};
friend class ResolveRecorder;