2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Make ObjCache of inner class of QPDF::Objects and rename to Entry

This commit is contained in:
m-holger 2024-10-07 16:50:08 +01:00
parent b5a5780019
commit 83443c116d
4 changed files with 17 additions and 19 deletions

View File

@ -748,7 +748,6 @@ class QPDF
static std::string const qpdf_version;
class ObjCache;
class ObjCopier;
class EncryptionParameters;
class ForeignStreamData;

View File

@ -747,8 +747,8 @@ Xref_table::read_stream(qpdf_offset_t xref_offset)
QPDFObjGen x_og;
QPDFObjectHandle xref_obj;
try {
xref_obj = qpdf.objects().read(
false, xref_offset, "xref stream", QPDFObjGen(0, 0), x_og, true);
xref_obj =
objects.read(false, xref_offset, "xref stream", QPDFObjGen(0, 0), x_og, true);
} catch (QPDFExc&) {
// ignore -- report error below
}
@ -1693,7 +1693,7 @@ Objects::update_table(QPDFObjGen og, const std::shared_ptr<QPDFObject>& object)
auto& cache = obj_cache[og];
cache.object->assign(object);
} else {
obj_cache[og] = ObjCache(object);
obj_cache[og] = Entry(object);
}
}
@ -1723,7 +1723,7 @@ QPDFObjectHandle
Objects::make_indirect(std::shared_ptr<QPDFObject> const& obj)
{
QPDFObjGen next{next_id()};
obj_cache[next] = ObjCache(obj);
obj_cache[next] = Entry(obj);
return qpdf.newIndirect(next, obj_cache[next].object);
}

View File

@ -375,6 +375,18 @@ class QPDF::Objects
qpdf_offset_t first_item_offset_{0}; // actual value from file
}; // Xref_table;
struct Entry
{
Entry() = default;
Entry(std::shared_ptr<QPDFObject> object) :
object(std::move(object))
{
}
std::shared_ptr<QPDFObject> object;
};
Objects(QPDF& qpdf, QPDF::Members* m, InputSource* const& file) :
qpdf(qpdf),
file(file),
@ -407,7 +419,7 @@ class QPDF::Objects
return xref.trailer();
}
std::map<QPDFObjGen, ObjCache> obj_cache;
std::map<QPDFObjGen, Entry> obj_cache;
QPDFObjectHandle readObjectInStream(std::shared_ptr<InputSource>& input, int obj);
QPDFObjectHandle read(

View File

@ -72,19 +72,6 @@ class QPDF::Pipe
}
};
class QPDF::ObjCache
{
public:
ObjCache() = default;
ObjCache(std::shared_ptr<QPDFObject> object) :
object(object)
{
}
std::shared_ptr<QPDFObject> object;
};
class QPDF::ObjCopier
{
public: