aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-11-20 14:56:03 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-11-20 18:07:22 +0100
commit0289b21c3b4d4d32b665e793dbf354ea34a23818 (patch)
tree1f261e72977fc3fdf24cdae2d1d580e6d29692dc
parent15e8d3a763e066e1a8d2bd54cc1e2117a54f7d7c (diff)
downloadqpdf-0289b21c3b4d4d32b665e793dbf354ea34a23818.tar.zst
Remove redundant QPDFObjectHandle::copyObject2
copyObject2 repeats a second time what new_obj = QPDFObjectHandle(obj->copy(true)) in shallowCopyInternal2 already did.
-rw-r--r--include/qpdf/QPDFObjectHandle.hh1
-rw-r--r--libqpdf/QPDFObjectHandle.cc64
2 files changed, 0 insertions, 65 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 718952fe..de9f51e9 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -1634,7 +1634,6 @@ class QPDFObjectHandle
bool first_level_only,
bool stop_at_streams);
void shallowCopyInternal1(QPDFObjectHandle& oh, bool first_level_only);
- void copyObject2(std::set<QPDFObjGen>& visited);
void shallowCopyInternal2(QPDFObjectHandle& oh);
void copyObject(
std::set<QPDFObjGen>& visited,
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 2a112166..242e0fb2 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -2312,70 +2312,6 @@ QPDFObjectHandle::shallowCopyInternal2(QPDFObjectHandle& new_obj)
throw std::runtime_error("attempt to make a shallow copy of a stream");
}
new_obj = QPDFObjectHandle(obj->copy(true));
-
- std::set<QPDFObjGen> visited;
- new_obj.copyObject2(visited);
-}
-
-void
-QPDFObjectHandle::copyObject2(std::set<QPDFObjGen>& visited)
-{
- assertInitialized();
-
- if (isStream()) {
- // same as obj->copy(true)
- throw std::runtime_error(
- "attempt to make a stream into a direct object");
- }
-
- auto cur_og = getObjGen();
- if (cur_og.getObj() != 0) {
- if (visited.count(cur_og)) {
- throw std::runtime_error(
- "loop detected while converting object from "
- "indirect to direct");
- }
- visited.insert(cur_og);
- }
-
- if (isReserved()) {
- // same as obj->copy(true)
- throw std::logic_error("QPDFObjectHandle: attempting to make a"
- " reserved object handle direct");
- }
-
- std::shared_ptr<QPDFObject> new_obj;
-
- if (isBool() || isInteger() || isName() || isNull() || isReal() ||
- isString()) {
- new_obj = obj->copy(true);
- } else if (isArray()) {
- // same as obj->copy(true)
- std::vector<QPDFObjectHandle> items;
- auto array = asArray();
- int n = array->getNItems();
- for (int i = 0; i < n; ++i) {
- items.push_back(array->getItem(i));
- }
- new_obj = QPDF_Array::create(items);
- } else if (isDictionary()) {
- // same as obj->copy(true)
- std::map<std::string, QPDFObjectHandle> items;
- auto dict = asDictionary();
- for (auto const& key: getKeys()) {
- items[key] = dict->getKey(key);
- }
- new_obj = QPDF_Dictionary::create(items);
- } else {
- throw std::logic_error("QPDFObjectHandle::makeDirectInternal: "
- "unknown object type");
- }
-
- this->obj = new_obj;
-
- if (cur_og.getObj()) {
- visited.erase(cur_og);
- }
}
void