Commit 97f737a562dcf7f50cec2060c9cc5a9dce06f58f

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 1eb2f208

Code tidy: QPDFJob::doJSONPageLabels

Remove redundant variables pages and next.
Showing 1 changed file with 4 additions and 7 deletions
libqpdf/QPDFJob.cc
@@ -1239,16 +1239,13 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool& first, QPDF& pdf) @@ -1239,16 +1239,13 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool& first, QPDF& pdf)
1239 { 1239 {
1240 JSON j_labels = JSON::makeArray(); 1240 JSON j_labels = JSON::makeArray();
1241 QPDFPageLabelDocumentHelper pldh(pdf); 1241 QPDFPageLabelDocumentHelper pldh(pdf);
1242 - QPDFPageDocumentHelper pdh(pdf);  
1243 - std::vector<QPDFPageObjectHelper> pages = pdh.getAllPages(); 1242 + long long npages = QIntC::to_longlong(
  1243 + QPDFPageDocumentHelper(pdf).getAllPages().size());
1244 if (pldh.hasPageLabels()) { 1244 if (pldh.hasPageLabels()) {
1245 std::vector<QPDFObjectHandle> labels; 1245 std::vector<QPDFObjectHandle> labels;
1246 - pldh.getLabelsForPageRange(  
1247 - 0, QIntC::to_int(pages.size()) - 1, 0, labels); 1246 + pldh.getLabelsForPageRange(0, npages - 1, 0, labels);
1248 for (auto iter = labels.begin(); iter != labels.end(); ++iter) { 1247 for (auto iter = labels.begin(); iter != labels.end(); ++iter) {
1249 - auto next = iter;  
1250 - ++next;  
1251 - if (next == labels.end()) { 1248 + if ((iter + 1) == labels.end()) {
1252 // This can't happen, so ignore it. This could only 1249 // This can't happen, so ignore it. This could only
1253 // happen if getLabelsForPageRange somehow returned an 1250 // happen if getLabelsForPageRange somehow returned an
1254 // odd number of items. 1251 // odd number of items.