diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-30 19:23:18 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-30 19:27:18 +0200 |
commit | 4f24617e1ea4ba7a6627a9c44304c6e0a0114249 (patch) | |
tree | 65c02e9e31cac60bac6f6aec165e8397dcde70e2 /libqpdf/QPDFPageDocumentHelper.cc | |
parent | 7f023701dd843749cf878baabeb3d33917fda62f (diff) | |
download | qpdf-4f24617e1ea4ba7a6627a9c44304c6e0a0114249.tar.zst |
Code clean up: use range-style for loops wherever possible
Where not possible, use "auto" to get the iterator type.
Editorial note: I have avoid this change for a long time because of
not wanting to make gratuitous changes to version history, which can
obscure when certain changes were made, but with having recently
touched every single file to apply automatic code formatting and with
making several broad changes to the API, I decided it was time to take
the plunge and get rid of the older (pre-C++11) verbose iterator
syntax. The new code is just easier to read and understand, and in
many cases, it will be more effecient as fewer temporary copies are
being made.
m-holger, if you're reading, you can see that I've finally come
around. :-)
Diffstat (limited to 'libqpdf/QPDFPageDocumentHelper.cc')
-rw-r--r-- | libqpdf/QPDFPageDocumentHelper.cc | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc index 61eba8c3..f54ad843 100644 --- a/libqpdf/QPDFPageDocumentHelper.cc +++ b/libqpdf/QPDFPageDocumentHelper.cc @@ -14,10 +14,8 @@ QPDFPageDocumentHelper::getAllPages() { std::vector<QPDFObjectHandle> const& pages_v = this->qpdf.getAllPages(); std::vector<QPDFPageObjectHelper> pages; - for (std::vector<QPDFObjectHandle>::const_iterator iter = pages_v.begin(); - iter != pages_v.end(); - ++iter) { - pages.push_back(QPDFPageObjectHelper(*iter)); + for (auto const& iter: pages_v) { + pages.push_back(QPDFPageObjectHelper(iter)); } return pages; } @@ -32,10 +30,8 @@ void QPDFPageDocumentHelper::removeUnreferencedResources() { std::vector<QPDFPageObjectHelper> pages = getAllPages(); - for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin(); - iter != pages.end(); - ++iter) { - (*iter).removeUnreferencedResources(); + for (auto& ph: pages) { + ph.removeUnreferencedResources(); } } @@ -71,10 +67,7 @@ QPDFPageDocumentHelper::flattenAnnotations( " so form fields will not be flattened"); } std::vector<QPDFPageObjectHelper> pages = getAllPages(); - for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin(); - iter != pages.end(); - ++iter) { - QPDFPageObjectHelper ph(*iter); + for (auto& ph: pages) { QPDFObjectHandle resources = ph.getAttribute("/Resources", true); if (!resources.isDictionary()) { // This should never happen and is not exercised in the @@ -107,11 +100,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( rotate = rotate_obj.getIntValueAsInt(); } int next_fx = 1; - for (std::vector<QPDFAnnotationObjectHelper>::iterator iter = - annots.begin(); - iter != annots.end(); - ++iter) { - QPDFAnnotationObjectHelper& aoh(*iter); + for (auto& aoh: annots) { QPDFObjectHandle as = aoh.getAppearanceStream("/N"); bool is_widget = (aoh.getSubtype() == "/Widget"); bool process = true; |