Commit 47b55307ac5f2767bb8f05e73bad3c86fc9df829
1 parent
5438f088
Refactor `getArrayNItems`: simplify logic, replace array check with `size()`, re…
…move redundant trace, and improve readability.
Showing
2 changed files
with
3 additions
and
4 deletions
libqpdf/QPDF_Array.cc
| @@ -350,11 +350,11 @@ Array::erase(int at_i) | @@ -350,11 +350,11 @@ Array::erase(int at_i) | ||
| 350 | int | 350 | int |
| 351 | QPDFObjectHandle::getArrayNItems() const | 351 | QPDFObjectHandle::getArrayNItems() const |
| 352 | { | 352 | { |
| 353 | - if (auto array = as_array(strict)) { | ||
| 354 | - return to_i(array.size()); | 353 | + auto s = size(); |
| 354 | + if (s > 1 || isArray()) { | ||
| 355 | + return to_i(s); | ||
| 355 | } | 356 | } |
| 356 | typeWarning("array", "treating as empty"); | 357 | typeWarning("array", "treating as empty"); |
| 357 | - QTC::TC("qpdf", "QPDFObjectHandle array treating as empty"); | ||
| 358 | return 0; | 358 | return 0; |
| 359 | } | 359 | } |
| 360 | 360 |
qpdf/qpdf.testcov
| @@ -299,7 +299,6 @@ QPDFObjectHandle string returning empty string 0 | @@ -299,7 +299,6 @@ QPDFObjectHandle string returning empty string 0 | ||
| 299 | QPDFObjectHandle string returning empty utf8 0 | 299 | QPDFObjectHandle string returning empty utf8 0 |
| 300 | QPDFObjectHandle operator returning fake value 0 | 300 | QPDFObjectHandle operator returning fake value 0 |
| 301 | QPDFObjectHandle inlineimage returning empty data 0 | 301 | QPDFObjectHandle inlineimage returning empty data 0 |
| 302 | -QPDFObjectHandle array treating as empty 0 | ||
| 303 | QPDFObjectHandle array null for non-array 0 | 302 | QPDFObjectHandle array null for non-array 0 |
| 304 | QPDFObjectHandle array treating as empty vector 0 | 303 | QPDFObjectHandle array treating as empty vector 0 |
| 305 | QPDFObjectHandle array ignoring set item 0 | 304 | QPDFObjectHandle array ignoring set item 0 |