From d8fdf632a979a7adb4a6423fd55ef1971fb06afd Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 29 Apr 2022 20:21:07 -0400 Subject: Use replaceKeyAndGet in a few places in existing code --- libqpdf/QPDFPageObjectHelper.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libqpdf/QPDFPageObjectHelper.cc') diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index b4e6a13a..a6773e70 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -597,8 +597,7 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper( for (auto const& iter : to_filter) { QPDFObjectHandle dict = resources.getKey(iter); if (dict.isDictionary()) { - dict = dict.shallowCopy(); - resources.replaceKey(iter, dict); + dict = resources.replaceKeyAndGet(iter, dict.shallowCopy()); rdicts.push_back(dict); auto keys = dict.getKeys(); known_names.insert(keys.begin(), keys.end()); @@ -1113,8 +1112,8 @@ QPDFPageObjectHelper::copyAnnotations( afdh->addAndRenameFormFields(new_fields); auto annots = this->oh.getKey("/Annots"); if (!annots.isArray()) { - annots = QPDFObjectHandle::newArray(); - this->oh.replaceKey("/Annots", annots); + annots = + this->oh.replaceKeyAndGet("/Annots", QPDFObjectHandle::newArray()); } for (auto const& annot : new_annots) { annots.appendItem(annot); -- cgit v1.2.3-54-g00ecf