aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-11-20 14:46:33 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-11-20 18:07:22 +0100
commit15e8d3a763e066e1a8d2bd54cc1e2117a54f7d7c (patch)
tree76bc1350aaf466b5c502a91826bb2800bcbb0cce
parent0827b1096e9041ffef2b4867164ba21f990d6892 (diff)
downloadqpdf-15e8d3a763e066e1a8d2bd54cc1e2117a54f7d7c.tar.zst
Remove redundant parameter first_level_only from QPDFObjectHandle::shallowCopyInternal2 and copyObject2
-rw-r--r--include/qpdf/QPDFObjectHandle.hh4
-rw-r--r--libqpdf/QPDFObjectHandle.cc22
2 files changed, 10 insertions, 16 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 4157015e..718952fe 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -1634,8 +1634,8 @@ class QPDFObjectHandle
bool first_level_only,
bool stop_at_streams);
void shallowCopyInternal1(QPDFObjectHandle& oh, bool first_level_only);
- void copyObject2(std::set<QPDFObjGen>& visited, bool first_level_only);
- void shallowCopyInternal2(QPDFObjectHandle& oh, bool first_level_only);
+ void copyObject2(std::set<QPDFObjGen>& visited);
+ void shallowCopyInternal2(QPDFObjectHandle& oh);
void copyObject(
std::set<QPDFObjGen>& visited,
bool cross_indirect,
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index a830fe4b..2a112166 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -2299,13 +2299,12 @@ QPDFObjectHandle
QPDFObjectHandle::unsafeShallowCopy()
{
QPDFObjectHandle result;
- shallowCopyInternal2(result, true);
+ shallowCopyInternal2(result);
return result;
}
void
-QPDFObjectHandle::shallowCopyInternal2(
- QPDFObjectHandle& new_obj, bool first_level_only)
+QPDFObjectHandle::shallowCopyInternal2(QPDFObjectHandle& new_obj)
{
assertInitialized();
@@ -2315,16 +2314,16 @@ QPDFObjectHandle::shallowCopyInternal2(
new_obj = QPDFObjectHandle(obj->copy(true));
std::set<QPDFObjGen> visited;
- new_obj.copyObject2(visited, first_level_only);
+ new_obj.copyObject2(visited);
}
void
-QPDFObjectHandle::copyObject2(
- std::set<QPDFObjGen>& visited, bool first_level_only)
+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");
}
@@ -2340,6 +2339,7 @@ QPDFObjectHandle::copyObject2(
}
if (isReserved()) {
+ // same as obj->copy(true)
throw std::logic_error("QPDFObjectHandle: attempting to make a"
" reserved object handle direct");
}
@@ -2350,26 +2350,20 @@ QPDFObjectHandle::copyObject2(
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));
- if ((!first_level_only) && !items.back().isIndirect())
- {
- items.back().copyObject2(visited, first_level_only);
- }
}
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);
- if ((!first_level_only) && !items[key].isIndirect())
- {
- items[key].copyObject2(visited, first_level_only);
- }
}
new_obj = QPDF_Dictionary::create(items);
} else {