Commit d784e8033c0aafce9becf720dfedf1872c74983e

Authored by m-holger
1 parent 0ac005f0

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

libqpdf/NNTree.cc
@@ -591,7 +591,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) @@ -591,7 +591,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
591 bool failed = false; 591 bool failed = false;
592 592
593 QPDFObjGen::set seen; 593 QPDFObjGen::set seen;
594 - for (auto i: this->path) { 594 + for (auto const& i: this->path) {
595 seen.add(i.node); 595 seen.add(i.node);
596 } 596 }
597 while (!failed) { 597 while (!failed) {
libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -70,7 +70,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle> @@ -70,7 +70,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
70 if (seen.add(obj)) { 70 if (seen.add(obj)) {
71 auto kids = obj.getKey("/Kids"); 71 auto kids = obj.getKey("/Kids");
72 if (kids.isArray()) { 72 if (kids.isArray()) {
73 - for (auto kid: kids.aitems()) { 73 + for (auto const& kid: kids.aitems()) {
74 queue.push_back(kid); 74 queue.push_back(kid);
75 } 75 }
76 } 76 }
@@ -104,7 +104,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle> @@ -104,7 +104,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
104 } 104 }
105 } 105 }
106 106
107 - for (auto i: fields) { 107 + for (auto const& i: fields) {
108 addFormField(i); 108 addFormField(i);
109 } 109 }
110 } 110 }
@@ -1018,7 +1018,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations( @@ -1018,7 +1018,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
1018 to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots)); 1018 to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
1019 addAndRenameFormFields(new_fields); 1019 addAndRenameFormFields(new_fields);
1020 if (added_fields) { 1020 if (added_fields) {
1021 - for (auto f: new_fields) { 1021 + for (auto const& f: new_fields) {
1022 added_fields->insert(f.getObjGen()); 1022 added_fields->insert(f.getObjGen());
1023 } 1023 }
1024 } 1024 }
libqpdf/QPDFJob.cc
@@ -894,7 +894,7 @@ QPDFJob::doListAttachments(QPDF& pdf) @@ -894,7 +894,7 @@ QPDFJob::doListAttachments(QPDF& pdf)
894 v << " " << i2.first << " -> " << i2.second << "\n"; 894 v << " " << i2.first << " -> " << i2.second << "\n";
895 } 895 }
896 v << " all data streams:\n"; 896 v << " all data streams:\n";
897 - for (auto i2: efoh->getEmbeddedFileStreams().ditems()) { 897 + for (auto const& i2: efoh->getEmbeddedFileStreams().ditems()) {
898 auto efs = QPDFEFStreamObjectHelper(i2.second); 898 auto efs = QPDFEFStreamObjectHelper(i2.second);
899 v << " " << i2.first << " -> " 899 v << " " << i2.first << " -> "
900 << efs.getObjectHandle().getObjGen().unparse(',') << "\n"; 900 << efs.getObjectHandle().getObjGen().unparse(',') << "\n";
@@ -1329,7 +1329,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1329,7 +1329,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1329 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second)); 1329 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
1330 } 1330 }
1331 auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary()); 1331 auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
1332 - for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) { 1332 + for (auto const& i2: fsoh->getEmbeddedFileStreams().ditems()) {
1333 auto efs = QPDFEFStreamObjectHelper(i2.second); 1333 auto efs = QPDFEFStreamObjectHelper(i2.second);
1334 auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary()); 1334 auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
1335 j_stream.addDictionaryMember( 1335 j_stream.addDictionaryMember(
libqpdf/QPDFObjectHandle.cc
@@ -1048,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf) @@ -1048,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf)
1048 if (!sub.isDictionary()) { 1048 if (!sub.isDictionary()) {
1049 continue; 1049 continue;
1050 } 1050 }
1051 - for (auto i2: sub.ditems()) { 1051 + for (auto const& i2: sub.ditems()) {
1052 std::string const& key = i2.first; 1052 std::string const& key = i2.first;
1053 QPDFObjectHandle val = i2.second; 1053 QPDFObjectHandle val = i2.second;
1054 if (!val.isIndirect()) { 1054 if (!val.isIndirect()) {
@@ -1069,7 +1069,7 @@ QPDFObjectHandle::mergeResources( @@ -1069,7 +1069,7 @@ QPDFObjectHandle::mergeResources(
1069 1069
1070 auto make_og_to_name = [](QPDFObjectHandle& dict, 1070 auto make_og_to_name = [](QPDFObjectHandle& dict,
1071 std::map<QPDFObjGen, std::string>& og_to_name) { 1071 std::map<QPDFObjGen, std::string>& og_to_name) {
1072 - for (auto i: dict.ditems()) { 1072 + for (auto const& i: dict.ditems()) {
1073 if (i.second.isIndirect()) { 1073 if (i.second.isIndirect()) {
1074 og_to_name[i.second.getObjGen()] = i.first; 1074 og_to_name[i.second.getObjGen()] = i.first;
1075 } 1075 }
@@ -1078,7 +1078,7 @@ QPDFObjectHandle::mergeResources( @@ -1078,7 +1078,7 @@ QPDFObjectHandle::mergeResources(
1078 1078
1079 // This algorithm is described in comments in QPDFObjectHandle.hh 1079 // This algorithm is described in comments in QPDFObjectHandle.hh
1080 // above the declaration of mergeResources. 1080 // above the declaration of mergeResources.
1081 - for (auto o_top: other.ditems()) { 1081 + for (auto const& o_top: other.ditems()) {
1082 std::string const& rtype = o_top.first; 1082 std::string const& rtype = o_top.first;
1083 QPDFObjectHandle other_val = o_top.second; 1083 QPDFObjectHandle other_val = o_top.second;
1084 if (hasKey(rtype)) { 1084 if (hasKey(rtype)) {
@@ -1095,7 +1095,7 @@ QPDFObjectHandle::mergeResources( @@ -1095,7 +1095,7 @@ QPDFObjectHandle::mergeResources(
1095 std::set<std::string> rnames; 1095 std::set<std::string> rnames;
1096 int min_suffix = 1; 1096 int min_suffix = 1;
1097 bool initialized_maps = false; 1097 bool initialized_maps = false;
1098 - for (auto ov_iter: other_val.ditems()) { 1098 + for (auto const& ov_iter: other_val.ditems()) {
1099 std::string const& key = ov_iter.first; 1099 std::string const& key = ov_iter.first;
1100 QPDFObjectHandle rval = ov_iter.second; 1100 QPDFObjectHandle rval = ov_iter.second;
1101 if (!this_val.hasKey(key)) { 1101 if (!this_val.hasKey(key)) {
qpdf/test_driver.cc
@@ -2576,7 +2576,7 @@ test_76(QPDF&amp; pdf, char const* arg2) @@ -2576,7 +2576,7 @@ test_76(QPDF&amp; pdf, char const* arg2)
2576 assert(efs2.getSubtype() == "text/plain"); 2576 assert(efs2.getSubtype() == "text/plain");
2577 assert(QUtil::hex_encode(efs2.getChecksum()) == "2fce9c8228e360ba9b04a1bd1bf63d6b"); 2577 assert(QUtil::hex_encode(efs2.getChecksum()) == "2fce9c8228e360ba9b04a1bd1bf63d6b");
2578 2578
2579 - for (auto iter: efdh.getEmbeddedFiles()) { 2579 + for (auto const& iter: efdh.getEmbeddedFiles()) {
2580 std::cout << iter.first << " -> " << iter.second->getFilename() << std::endl; 2580 std::cout << iter.first << " -> " << iter.second->getFilename() << std::endl;
2581 } 2581 }
2582 assert(efdh.getEmbeddedFile("att1")->getFilename() == "att1.txt"); 2582 assert(efdh.getEmbeddedFile("att1")->getFilename() == "att1.txt");