From 1831a2fe379b44f11d8974685260c1ef143e880a Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 4 Nov 2025 14:04:15 +0000 Subject: [PATCH] Refactor `QPDF::getExtensionLevel`: simplify key lookup logic and improve readability. --- libqpdf/QPDF.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 5c7338b..9e444ce 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -635,21 +635,11 @@ QPDF::getPDFVersion() const int QPDF::getExtensionLevel() { - int result = 0; - QPDFObjectHandle obj = getRoot(); - if (obj.hasKey("/Extensions")) { - obj = obj.getKey("/Extensions"); - if (obj.isDictionary() && obj.hasKey("/ADBE")) { - obj = obj.getKey("/ADBE"); - if (obj.isDictionary() && obj.hasKey("/ExtensionLevel")) { - obj = obj.getKey("/ExtensionLevel"); - if (obj.isInteger()) { - result = obj.getIntValueAsInt(); - } - } - } + if (Integer ExtensionLevel = getRoot()["/Extensions"]["/ADBE"]["/ExtensionLevel"]) { + int result = ExtensionLevel; + return result; } - return result; + return 0; } QPDFObjectHandle -- libgit2 0.21.4