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/QPDFWriter.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libqpdf/QPDFWriter.cc') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 9f3eacbe..d06a82b0 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1662,8 +1662,8 @@ QPDFWriter::unparseObject( "qpdf", "QPDFWriter create Extensions", this->m->qdf_mode ? 0 : 1); - extensions = QPDFObjectHandle::newDictionary(); - object.replaceKey("/Extensions", extensions); + extensions = object.replaceKeyAndGet( + "/Extensions", QPDFObjectHandle::newDictionary()); } } else if (!have_extensions_other) { // We have Extensions dictionary and don't want one. @@ -2387,8 +2387,7 @@ QPDFWriter::prepareFileForWrite() if (oh.isIndirect()) { QTC::TC("qpdf", "QPDFWriter make Extensions direct"); extensions_indirect = true; - oh = oh.shallowCopy(); - root.replaceKey(key, oh); + oh = root.replaceKeyAndGet(key, oh.shallowCopy()); } if (oh.hasKey("/ADBE")) { QPDFObjectHandle adbe = oh.getKey("/ADBE"); -- cgit v1.2.3-70-g09d2