Commit 47b55307ac5f2767bb8f05e73bad3c86fc9df829

Authored by m-holger
1 parent 5438f088

Refactor `getArrayNItems`: simplify logic, replace array check with `size()`, re…

…move redundant trace, and improve readability.
libqpdf/QPDF_Array.cc
... ... @@ -350,11 +350,11 @@ Array::erase(int at_i)
350 350 int
351 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 357 typeWarning("array", "treating as empty");
357   - QTC::TC("qpdf", "QPDFObjectHandle array treating as empty");
358 358 return 0;
359 359 }
360 360  
... ...
qpdf/qpdf.testcov
... ... @@ -299,7 +299,6 @@ QPDFObjectHandle string returning empty string 0
299 299 QPDFObjectHandle string returning empty utf8 0
300 300 QPDFObjectHandle operator returning fake value 0
301 301 QPDFObjectHandle inlineimage returning empty data 0
302   -QPDFObjectHandle array treating as empty 0
303 302 QPDFObjectHandle array null for non-array 0
304 303 QPDFObjectHandle array treating as empty vector 0
305 304 QPDFObjectHandle array ignoring set item 0
... ...