2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Performance: remove indirection through Members for QPDFObject

This commit is contained in:
Jay Berkenbilt 2020-04-02 18:52:31 -04:00
parent 89f19b7099
commit 07afb668b1
2 changed files with 15 additions and 34 deletions

View File

@ -24,7 +24,6 @@
#include <qpdf/DLL.h> #include <qpdf/DLL.h>
#include <qpdf/Types.h> #include <qpdf/Types.h>
#include <qpdf/PointerHolder.hh>
#include <qpdf/JSON.hh> #include <qpdf/JSON.hh>
#include <string> #include <string>
@ -100,21 +99,12 @@ class QPDFObject
virtual void releaseResolved() {} virtual void releaseResolved() {}
private: private:
QPDFObject(QPDFObject const&); QPDFObject(QPDFObject const&) = delete;
QPDFObject& operator=(QPDFObject const&); QPDFObject& operator=(QPDFObject const&) = delete;
class Members
{ QPDF* owning_qpdf;
friend class QPDFObject; std::string object_description;
public: qpdf_offset_t parsed_offset;
QPDF_DLL
~Members();
private:
Members();
QPDF* owning_qpdf;
std::string object_description;
qpdf_offset_t parsed_offset;
};
PointerHolder<Members> m;
}; };
#endif // QPDFOBJECT_HH #endif // QPDFOBJECT_HH

View File

@ -1,49 +1,40 @@
#include <qpdf/QPDFObject.hh> #include <qpdf/QPDFObject.hh>
QPDFObject::Members::Members() : QPDFObject::QPDFObject() :
owning_qpdf(0), owning_qpdf(0),
parsed_offset(-1) parsed_offset(-1)
{ {
} }
QPDFObject::Members::~Members()
{
}
QPDFObject::QPDFObject() :
m(new Members)
{
}
void void
QPDFObject::setDescription(QPDF* qpdf, std::string const& description) QPDFObject::setDescription(QPDF* qpdf, std::string const& description)
{ {
this->m->owning_qpdf = qpdf; this->owning_qpdf = qpdf;
this->m->object_description = description; this->object_description = description;
} }
bool bool
QPDFObject::getDescription(QPDF*& qpdf, std::string& description) QPDFObject::getDescription(QPDF*& qpdf, std::string& description)
{ {
qpdf = this->m->owning_qpdf; qpdf = this->owning_qpdf;
description = this->m->object_description; description = this->object_description;
return this->m->owning_qpdf != 0; return this->owning_qpdf != 0;
} }
bool bool
QPDFObject::hasDescription() QPDFObject::hasDescription()
{ {
return this->m->owning_qpdf != 0; return this->owning_qpdf != 0;
} }
void void
QPDFObject::setParsedOffset(qpdf_offset_t offset) QPDFObject::setParsedOffset(qpdf_offset_t offset)
{ {
this->m->parsed_offset = offset; this->parsed_offset = offset;
} }
qpdf_offset_t qpdf_offset_t
QPDFObject::getParsedOffset() QPDFObject::getParsedOffset()
{ {
return this->m->parsed_offset; return this->parsed_offset;
} }