summaryrefslogtreecommitdiffstats
path: root/libqpdf/SparseOHArray.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-11-14 23:06:04 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-11-20 18:07:22 +0100
commitb1eb1a958438025efbf90f7a7f45dbe33c746d91 (patch)
treef9ff3400204d1ca1e878c94b240eb0d1e1704e3f /libqpdf/SparseOHArray.cc
parent3e3b79a774a294ca2020a7bad8ee6ddd2c0179de (diff)
downloadqpdf-b1eb1a958438025efbf90f7a7f45dbe33c746d91.tar.zst
Refactor QPDFObjectHandle::copyObject1
Diffstat (limited to 'libqpdf/SparseOHArray.cc')
-rw-r--r--libqpdf/SparseOHArray.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/libqpdf/SparseOHArray.cc b/libqpdf/SparseOHArray.cc
index 6ff02f6c..567f9d0b 100644
--- a/libqpdf/SparseOHArray.cc
+++ b/libqpdf/SparseOHArray.cc
@@ -110,6 +110,19 @@ SparseOHArray::insert(size_t idx, QPDFObjectHandle oh)
}
}
+SparseOHArray
+SparseOHArray::copy()
+{
+ SparseOHArray result;
+ result.n_elements = this->n_elements;
+ for (auto const& element: this->elements) {
+ auto value = element.second;
+ result.elements[element.first] =
+ value.isIndirect() ? value : value.shallowCopy();
+ }
+ return result;
+}
+
SparseOHArray::const_iterator
SparseOHArray::begin() const
{