aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-10 14:16:06 +0200
committerm-holger <m-holger@kubitscheck.org>2022-09-01 15:30:26 +0200
commit556c34f0f225bfc6eaeb617693e0161fbce5f2f3 (patch)
treee0f5a54a38c8aeda4f4f75ff1382841e9eed5ea2 /libqpdf
parentc0cd72a3eef996e597ba82b784de029ec6d88707 (diff)
downloadqpdf-556c34f0f225bfc6eaeb617693e0161fbce5f2f3.tar.zst
Add private method QPDF::ObjCache::update
Add a new obj_cache entry or update an existing entry in place.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index d877c14a..80cc34cc 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2111,6 +2111,23 @@ QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
return QPDFObjectHandle::Factory::newIndirect(this, og, obj);
}
+void
+QPDF::updateCache(
+ QPDFObjGen const& og,
+ std::shared_ptr<QPDFObject> const& object,
+ qpdf_offset_t end_before_space,
+ qpdf_offset_t end_after_space)
+{
+ if (isCached(og)) {
+ auto& cache = m->obj_cache[og];
+ cache.object->assign(object);
+ cache.end_before_space = end_before_space;
+ cache.end_after_space = end_after_space;
+ } else {
+ m->obj_cache[og] = ObjCache(object, end_before_space, end_after_space);
+ }
+}
+
bool
QPDF::isCached(QPDFObjGen const& og)
{
@@ -2199,8 +2216,7 @@ QPDF::replaceObject(QPDFObjGen const& og, QPDFObjectHandle oh)
resolve(og);
// Replace the object in the object cache
- m->obj_cache[og].object->assign(
- QPDFObjectHandle::ObjAccessor::getObject(oh));
+ updateCache(og, QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
}
void