From b776dcd2d3180becef8f58158873a91004e324ee Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 29 Jan 2019 22:04:52 -0500 Subject: Clean up some private functions --- libqpdf/QPDF_optimization.cc | 19 ++++--------------- libqpdf/QPDF_pages.cc | 30 ++++++++---------------------- 2 files changed, 12 insertions(+), 37 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc index ecece7db..5d959f10 100644 --- a/libqpdf/QPDF_optimization.cc +++ b/libqpdf/QPDF_optimization.cc @@ -163,9 +163,11 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) // Pages nodes that contain values for them. std::map > key_ancestors; this->m->all_pages.clear(); + std::set visited; pushInheritedAttributesToPageInternal( this->m->trailer.getKey("/Root").getKey("/Pages"), - key_ancestors, this->m->all_pages, allow_changes, warn_skipped_keys); + key_ancestors, this->m->all_pages, allow_changes, warn_skipped_keys, + visited); if (! key_ancestors.empty()) { throw std::logic_error( @@ -177,19 +179,6 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) void QPDF::pushInheritedAttributesToPageInternal( - QPDFObjectHandle cur_pages, - std::map >& key_ancestors, - std::vector& pages, - bool allow_changes, bool warn_skipped_keys) -{ - std::set visited; - pushInheritedAttributesToPageInternal2( - cur_pages, key_ancestors, pages, allow_changes, - warn_skipped_keys, visited); -} - -void -QPDF::pushInheritedAttributesToPageInternal2( QPDFObjectHandle cur_pages, std::map >& key_ancestors, std::vector& pages, @@ -291,7 +280,7 @@ QPDF::pushInheritedAttributesToPageInternal2( int n = kids.getArrayNItems(); for (int i = 0; i < n; ++i) { - pushInheritedAttributesToPageInternal2( + pushInheritedAttributesToPageInternal( kids.getArrayItem(i), key_ancestors, pages, allow_changes, warn_skipped_keys, visited); } diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc index 01270652..f4156d03 100644 --- a/libqpdf/QPDF_pages.cc +++ b/libqpdf/QPDF_pages.cc @@ -47,33 +47,19 @@ QPDF::getAllPages() // initialize this->m->all_pages. if (this->m->all_pages.empty()) { - getAllPagesInternal(getRoot().getKey("/Pages"), this->m->all_pages); + std::set visited; + std::set seen; + getAllPagesInternal(getRoot().getKey("/Pages"), this->m->all_pages, + visited, seen); } return this->m->all_pages; } void QPDF::getAllPagesInternal(QPDFObjectHandle cur_pages, - std::vector& result) -{ - std::set visited; - getAllPagesInternal2(cur_pages, result, visited); -} - -void -QPDF::getAllPagesInternal2(QPDFObjectHandle cur_pages, - std::vector& result, - std::set& visited) -{ - std::set seen; - getAllPagesInternal3(cur_pages, result, visited, seen); -} - -void -QPDF::getAllPagesInternal3(QPDFObjectHandle cur_pages, - std::vector& result, - std::set& visited, - std::set& seen) + std::vector& result, + std::set& visited, + std::set& seen) { QPDFObjGen this_og = cur_pages.getObjGen(); if (visited.count(this_og) > 0) @@ -119,7 +105,7 @@ QPDF::getAllPagesInternal3(QPDFObjectHandle cur_pages, kid = makeIndirectObject(QPDFObjectHandle(kid).shallowCopy()); kids.setArrayItem(i, kid); } - getAllPagesInternal3(kid, result, visited, seen); + getAllPagesInternal(kid, result, visited, seen); } } else if (type == "/Page") -- cgit v1.2.3-54-g00ecf