diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc index 247d3c86..f75935aa 100644 --- a/libqpdf/JSON.cc +++ b/libqpdf/JSON.cc @@ -346,7 +346,7 @@ JSON::checkSchemaInternal(JSON_value* this_v, JSON_value* sch_v, if (sch_dict && (! pattern_key.empty())) { auto pattern_schema = sch_dict->members[pattern_key].getPointer(); - for (auto iter: this_dict->members) + for (auto const& iter: this_dict->members) { std::string const& key = iter.first; checkSchemaInternal( diff --git a/libqpdf/QPDFCryptoProvider.cc b/libqpdf/QPDFCryptoProvider.cc index b375498d..5f65da3b 100644 --- a/libqpdf/QPDFCryptoProvider.cc +++ b/libqpdf/QPDFCryptoProvider.cc @@ -110,10 +110,9 @@ QPDFCryptoProvider::getRegisteredImpls() { std::set result; QPDFCryptoProvider& p = getInstance(); - for (auto iter = p.m->providers.begin(); iter != p.m->providers.end(); - ++iter) + for (auto const& iter: p.m->providers) { - result.insert((*iter).first); + result.insert(iter.first); } return result; } diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index 609e9d77..d2091fab 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -146,9 +146,8 @@ QPDF_Array::getElementsForShallowCopy() const void QPDF_Array::addExplicitElementsToList(std::list& l) const { - for (auto iter = this->elements.begin(); - iter != this->elements.end(); ++iter) + for (auto const& iter: this->elements) { - l.push_back((*iter).second); + l.push_back(iter.second); } } diff --git a/libqpdf/SparseOHArray.cc b/libqpdf/SparseOHArray.cc index 48ddce0f..c8aaefa8 100644 --- a/libqpdf/SparseOHArray.cc +++ b/libqpdf/SparseOHArray.cc @@ -30,7 +30,7 @@ SparseOHArray::at(size_t idx) const throw std::logic_error( "INTERNAL ERROR: bounds error accessing SparseOHArray element"); } - auto iter = this->elements.find(idx); + auto const& iter = this->elements.find(idx); if (iter == this->elements.end()) { return QPDFObjectHandle::newNull(); @@ -57,10 +57,9 @@ SparseOHArray::remove_last() void SparseOHArray::releaseResolved() { - for (auto iter = this->elements.begin(); - iter != this->elements.end(); ++iter) + for (auto iter: this->elements) { - QPDFObjectHandle::ReleaseResolver::releaseResolved((*iter).second); + QPDFObjectHandle::ReleaseResolver::releaseResolved(iter.second); } } @@ -89,16 +88,15 @@ SparseOHArray::erase(size_t idx) throw std::logic_error("bounds error erasing item from SparseOHArray"); } decltype(this->elements) dest; - for (auto iter = this->elements.begin(); - iter != this->elements.end(); ++iter) + for (auto const& iter: this->elements) { - if ((*iter).first < idx) + if (iter.first < idx) { - dest.insert(*iter); + dest.insert(iter); } - else if ((*iter).first > idx) + else if (iter.first > idx) { - dest[(*iter).first - 1] = (*iter).second; + dest[iter.first - 1] = iter.second; } } this->elements = dest; @@ -120,16 +118,15 @@ SparseOHArray::insert(size_t idx, QPDFObjectHandle oh) else { decltype(this->elements) dest; - for (auto iter = this->elements.begin(); - iter != this->elements.end(); ++iter) + for (auto const& iter: this->elements) { - if ((*iter).first < idx) + if (iter.first < idx) { - dest.insert(*iter); + dest.insert(iter); } else { - dest[(*iter).first + 1] = (*iter).second; + dest[iter.first + 1] = iter.second; } } this->elements = dest; diff --git a/qpdf/fix-qdf.cc b/qpdf/fix-qdf.cc index 2516a0bd..c50f7b5a 100644 --- a/qpdf/fix-qdf.cc +++ b/qpdf/fix-qdf.cc @@ -387,13 +387,12 @@ QdfFixer::writeOstream() auto onum = ostream_id; std::string offsets; auto n = ostream_offsets.size(); - for (auto iter = ostream_offsets.begin(); - iter != ostream_offsets.end(); ++iter) + for (auto iter: ostream_offsets) { - (*iter) -= QIntC::to_offset(first); + iter -= QIntC::to_offset(first); ++onum; offsets += QUtil::int_to_string(onum) + " " + - QUtil::int_to_string(*iter) + "\n"; + QUtil::int_to_string(iter) + "\n"; } auto offset_adjust = QIntC::to_offset(offsets.size()); first += offset_adjust; diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index fd6060e0..f11ade43 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -1694,11 +1694,11 @@ ArgParser::argShowCrypto() auto crypto = QPDFCryptoProvider::getRegisteredImpls(); std::string default_crypto = QPDFCryptoProvider::getDefaultProvider(); std::cout << default_crypto << std::endl; - for (auto iter = crypto.begin(); iter != crypto.end(); ++iter) + for (auto const& iter: crypto) { - if (*iter != default_crypto) + if (iter != default_crypto) { - std::cout << *iter << std::endl; + std::cout << iter << std::endl; } } } @@ -3646,7 +3646,7 @@ static std::set get_wanted_json_objects(Options& o) { std::set wanted_og; - for (auto iter: o.json_objects) + for (auto const& iter: o.json_objects) { bool trailer; int obj = 0;