Commit a03c5fce136e44135380318322984e77cd637f4f
1 parent
9a84ef3b
Simplify stream filtering logic and remove unused variable.
Removed the unnecessary `filterable` variable and streamlined the logic for handling stream decoding parameters. These changes eliminate redundant checks, improve readability, and ensure clarity in flow control for filter processing.
Showing
1 changed file
with
11 additions
and
17 deletions
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -382,8 +382,6 @@ Stream::filterable( |
| 382 | 382 | return false; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - bool filterable = true; | |
| 386 | - | |
| 387 | 385 | // filters now contains a list of filters to be applied in order. See which ones we can support. |
| 388 | 386 | |
| 389 | 387 | // See if we can support any decode parameters that are specified. |
| ... | ... | @@ -407,10 +405,6 @@ Stream::filterable( |
| 407 | 405 | // /DecodeParms was [ << >> ] when /Filters was empty has been seen in the wild. |
| 408 | 406 | if ((filters.size() != 0) && (decode_parms.size() != filters.size())) { |
| 409 | 407 | warn("stream /DecodeParms length is inconsistent with filters"); |
| 410 | - filterable = false; | |
| 411 | - } | |
| 412 | - | |
| 413 | - if (!filterable) { | |
| 414 | 408 | return false; |
| 415 | 409 | } |
| 416 | 410 | |
| ... | ... | @@ -418,20 +412,20 @@ Stream::filterable( |
| 418 | 412 | auto filter = filters.at(i); |
| 419 | 413 | auto decode_item = decode_parms.at(i); |
| 420 | 414 | |
| 421 | - if (filter->setDecodeParms(decode_item)) { | |
| 422 | - if (filter->isSpecializedCompression()) { | |
| 423 | - specialized_compression = true; | |
| 424 | - } | |
| 425 | - if (filter->isLossyCompression()) { | |
| 426 | - specialized_compression = true; | |
| 427 | - lossy_compression = true; | |
| 428 | - } | |
| 429 | - } else { | |
| 430 | - filterable = false; | |
| 415 | + if (!filter->setDecodeParms(decode_item)) { | |
| 416 | + return false; | |
| 417 | + } | |
| 418 | + if (filter->isLossyCompression()) { | |
| 419 | + specialized_compression = true; | |
| 420 | + lossy_compression = true; | |
| 421 | + continue; | |
| 422 | + } | |
| 423 | + if (filter->isSpecializedCompression()) { | |
| 424 | + specialized_compression = true; | |
| 431 | 425 | } |
| 432 | 426 | } |
| 433 | 427 | |
| 434 | - return filterable; | |
| 428 | + return true; | |
| 435 | 429 | } |
| 436 | 430 | |
| 437 | 431 | bool | ... | ... |