From 0dad57c5611d0aa31d583b9470efe6de0ac9f18b Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 2 Sep 2025 14:49:52 +0100 Subject: [PATCH] Refactor: replace `getKey` with operator[] in `QPDF_linearization::`, update type handling to improve clarity and consistency. --- libqpdf/QPDF_linearization.cc | 19 +++++-------------- qpdf/qpdf.testcov | 1 - 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index bcce0e6..1af95c0 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -122,27 +122,18 @@ QPDF::isLinearized() continue; } - auto candidate = getObject(toI(QUtil::string_to_ll(t1.getValue().data())), 0); - if (!candidate.isDictionary()) { - return false; - } - - auto linkey = candidate.getKey("/Linearized"); + Dictionary candidate = getObject(toI(QUtil::string_to_ll(t1.getValue().data())), 0); + auto linkey = candidate["/Linearized"]; if (!(linkey.isNumber() && toI(floor(linkey.getNumericValue())) == 1)) { return false; } - auto L = candidate.getKey("/L"); - if (!L.isInteger()) { - return false; - } - qpdf_offset_t Li = L.getIntValue(); m->file->seek(0, SEEK_END); - if (Li != m->file->tell()) { - QTC::TC("qpdf", "QPDF /L mismatch"); + Integer L = candidate["/L"]; + if (L != m->file->tell()) { return false; } - m->linp.file_size = Li; + m->linp.file_size = L; m->lindict = candidate; return true; } diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index a0ddbd0..9f4c772 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -12,7 +12,6 @@ QPDF hint table length direct 0 QPDF P absent in lindict 0 QPDF P present in lindict 0 QPDF expected n n obj 0 -QPDF /L mismatch 0 QPDF err /T mismatch 0 QPDF err /O mismatch 0 QPDF opt direct pages resource 1 -- libgit2 0.21.4