2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Code tidy - Clang-Tidy rule performance-for-range-copy

This commit is contained in:
m-holger 2023-06-01 16:16:21 +01:00
parent 0ac005f0d9
commit d784e8033c
5 changed files with 11 additions and 11 deletions

View File

@ -591,7 +591,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
bool failed = false;
QPDFObjGen::set seen;
for (auto i: this->path) {
for (auto const& i: this->path) {
seen.add(i.node);
}
while (!failed) {

View File

@ -70,7 +70,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
if (seen.add(obj)) {
auto kids = obj.getKey("/Kids");
if (kids.isArray()) {
for (auto kid: kids.aitems()) {
for (auto const& kid: kids.aitems()) {
queue.push_back(kid);
}
}
@ -104,7 +104,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
}
}
for (auto i: fields) {
for (auto const& i: fields) {
addFormField(i);
}
}
@ -1018,7 +1018,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
addAndRenameFormFields(new_fields);
if (added_fields) {
for (auto f: new_fields) {
for (auto const& f: new_fields) {
added_fields->insert(f.getObjGen());
}
}

View File

@ -894,7 +894,7 @@ QPDFJob::doListAttachments(QPDF& pdf)
v << " " << i2.first << " -> " << i2.second << "\n";
}
v << " all data streams:\n";
for (auto i2: efoh->getEmbeddedFileStreams().ditems()) {
for (auto const& i2: efoh->getEmbeddedFileStreams().ditems()) {
auto efs = QPDFEFStreamObjectHelper(i2.second);
v << " " << i2.first << " -> "
<< efs.getObjectHandle().getObjGen().unparse(',') << "\n";
@ -1329,7 +1329,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf)
j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
}
auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) {
for (auto const& i2: fsoh->getEmbeddedFileStreams().ditems()) {
auto efs = QPDFEFStreamObjectHelper(i2.second);
auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
j_stream.addDictionaryMember(

View File

@ -1048,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF& owning_qpdf)
if (!sub.isDictionary()) {
continue;
}
for (auto i2: sub.ditems()) {
for (auto const& i2: sub.ditems()) {
std::string const& key = i2.first;
QPDFObjectHandle val = i2.second;
if (!val.isIndirect()) {
@ -1069,7 +1069,7 @@ QPDFObjectHandle::mergeResources(
auto make_og_to_name = [](QPDFObjectHandle& dict,
std::map<QPDFObjGen, std::string>& og_to_name) {
for (auto i: dict.ditems()) {
for (auto const& i: dict.ditems()) {
if (i.second.isIndirect()) {
og_to_name[i.second.getObjGen()] = i.first;
}
@ -1078,7 +1078,7 @@ QPDFObjectHandle::mergeResources(
// This algorithm is described in comments in QPDFObjectHandle.hh
// above the declaration of mergeResources.
for (auto o_top: other.ditems()) {
for (auto const& o_top: other.ditems()) {
std::string const& rtype = o_top.first;
QPDFObjectHandle other_val = o_top.second;
if (hasKey(rtype)) {
@ -1095,7 +1095,7 @@ QPDFObjectHandle::mergeResources(
std::set<std::string> rnames;
int min_suffix = 1;
bool initialized_maps = false;
for (auto ov_iter: other_val.ditems()) {
for (auto const& ov_iter: other_val.ditems()) {
std::string const& key = ov_iter.first;
QPDFObjectHandle rval = ov_iter.second;
if (!this_val.hasKey(key)) {

View File

@ -2576,7 +2576,7 @@ test_76(QPDF& pdf, char const* arg2)
assert(efs2.getSubtype() == "text/plain");
assert(QUtil::hex_encode(efs2.getChecksum()) == "2fce9c8228e360ba9b04a1bd1bf63d6b");
for (auto iter: efdh.getEmbeddedFiles()) {
for (auto const& iter: efdh.getEmbeddedFiles()) {
std::cout << iter.first << " -> " << iter.second->getFilename() << std::endl;
}
assert(efdh.getEmbeddedFile("att1")->getFilename() == "att1.txt");