Commit 4a4b94568ffd4497d6d5aaab0df77c74ddbedd4a
1 parent
6a599276
In QPDF::interpretCF refactor crypt filter lookup for clarity and efficiency
Replace `count` method with iterator-based lookup to improve readability and reduce redundancy. Simplify conditional logic for determining the encryption filter, ensuring the default case remains clear.
Showing
2 changed files
with
9 additions
and
13 deletions
libqpdf/JSON.cc
| ... | ... | @@ -494,11 +494,7 @@ JSON::checkSchemaInternal( |
| 494 | 494 | auto pattern_schema = sch_dict->members[pattern_key].m->value.get(); |
| 495 | 495 | for (auto const& [key, val]: this_dict->members) { |
| 496 | 496 | checkSchemaInternal( |
| 497 | - val.m->value.get(), | |
| 498 | - pattern_schema, | |
| 499 | - flags, | |
| 500 | - errors, | |
| 501 | - prefix + "." + key); | |
| 497 | + val.m->value.get(), pattern_schema, flags, errors, prefix + "." + key); | |
| 502 | 498 | } |
| 503 | 499 | } else if (sch_dict) { |
| 504 | 500 | for (auto& [key, val]: sch_dict->members) { | ... | ... |
libqpdf/QPDF_encryption.cc
| ... | ... | @@ -702,17 +702,17 @@ QPDF::interpretCF(std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle c |
| 702 | 702 | { |
| 703 | 703 | if (cf.isName()) { |
| 704 | 704 | std::string filter = cf.getName(); |
| 705 | - if (encp->crypt_filters.count(filter) != 0) { | |
| 706 | - return encp->crypt_filters[filter]; | |
| 707 | - } else if (filter == "/Identity") { | |
| 705 | + auto it = encp->crypt_filters.find(filter); | |
| 706 | + if (it != encp->crypt_filters.end()) { | |
| 707 | + return it->second; | |
| 708 | + } | |
| 709 | + if (filter == "/Identity") { | |
| 708 | 710 | return e_none; |
| 709 | - } else { | |
| 710 | - return e_unknown; | |
| 711 | 711 | } |
| 712 | - } else { | |
| 713 | - // Default: /Identity | |
| 714 | - return e_none; | |
| 712 | + return e_unknown; | |
| 715 | 713 | } |
| 714 | + // Default: /Identity | |
| 715 | + return e_none; | |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | void | ... | ... |