From 3052c45155e76e3c7a01f297a1646f9afa0cc531 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 18 Aug 2025 14:35:18 +0100 Subject: [PATCH] Refactor `QPDFObjectHandle::eraseItemAndGetOld`: replace `as_array` and bounds checks with `Array` subscript operator, simplify logic, and improve null handling. --- libqpdf/QPDF_Array.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index b6a31fc..3077b11 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -530,11 +530,9 @@ QPDFObjectHandle::eraseItem(int at) QPDFObjectHandle QPDFObjectHandle::eraseItemAndGetOld(int at) { - auto array = as_array(strict); - auto result = - (array && std::cmp_less(at, array.size()) && at >= 0) ? array.at(at).second : newNull(); + auto result = Array(*this)[at]; eraseItem(at); - return result; + return result ? result : newNull(); } size_t -- libgit2 0.21.4