Commit 3052c45155e76e3c7a01f297a1646f9afa0cc531
1 parent
53acbf15
Refactor `QPDFObjectHandle::eraseItemAndGetOld`: replace `as_array` and bounds c…
…hecks with `Array` subscript operator, simplify logic, and improve null handling.
Showing
1 changed file
with
2 additions
and
4 deletions
libqpdf/QPDF_Array.cc
| ... | ... | @@ -530,11 +530,9 @@ QPDFObjectHandle::eraseItem(int at) |
| 530 | 530 | QPDFObjectHandle |
| 531 | 531 | QPDFObjectHandle::eraseItemAndGetOld(int at) |
| 532 | 532 | { |
| 533 | - auto array = as_array(strict); | |
| 534 | - auto result = | |
| 535 | - (array && std::cmp_less(at, array.size()) && at >= 0) ? array.at(at).second : newNull(); | |
| 533 | + auto result = Array(*this)[at]; | |
| 536 | 534 | eraseItem(at); |
| 537 | - return result; | |
| 535 | + return result ? result : newNull(); | |
| 538 | 536 | } |
| 539 | 537 | |
| 540 | 538 | size_t | ... | ... |