Commit 5f347f3523fc6e34d55a6520b2b7b842c1b54e84
1 parent
36e92e03
Simplify decode parameters handling in streams
Refactored the handling of /DecodeParms by removing unnecessary vector creation and directly accessing elements in the decode array. This improves code clarity and maintains consistency with filters processing.
Showing
1 changed file
with
4 additions
and
10 deletions
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -407,22 +407,16 @@ Stream::filterable( |
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | } else { |
| 410 | - std::vector<QPDFObjectHandle> decode_parms; | |
| 411 | - for (auto& item: decode_array) { | |
| 412 | - decode_parms.emplace_back(item); | |
| 413 | - } | |
| 414 | 410 | // Ignore /DecodeParms entirely if /Filters is empty. At least one case of a file whose |
| 415 | 411 | // /DecodeParms was [ << >> ] when /Filters was empty has been seen in the wild. |
| 416 | - if (!filters.empty() && decode_parms.size() != filters.size()) { | |
| 412 | + if (!filters.empty() && QIntC::to_size(decode_array.size()) != filters.size()) { | |
| 417 | 413 | warn("stream /DecodeParms length is inconsistent with filters"); |
| 418 | 414 | return false; |
| 419 | 415 | } |
| 420 | 416 | |
| 421 | - for (size_t i = 0; i < filters.size(); ++i) { | |
| 422 | - auto filter = filters.at(i); | |
| 423 | - auto decode_item = decode_parms.at(i); | |
| 424 | - | |
| 425 | - if (!filter->setDecodeParms(decode_item)) { | |
| 417 | + int i = -1; | |
| 418 | + for (auto& filter: filters) { | |
| 419 | + if (!filter->setDecodeParms(decode_array.at(++i).second)) { | |
| 426 | 420 | return false; |
| 427 | 421 | } |
| 428 | 422 | if (filter->isLossyCompression()) { | ... | ... |