Commit 1831a2fe379b44f11d8974685260c1ef143e880a

Authored by m-holger
1 parent 2d6512eb

Refactor `QPDF::getExtensionLevel`: simplify key lookup logic and improve readability.

Showing 1 changed file with 4 additions and 14 deletions
libqpdf/QPDF.cc
... ... @@ -635,21 +635,11 @@ QPDF::getPDFVersion() const
635 635 int
636 636 QPDF::getExtensionLevel()
637 637 {
638   - int result = 0;
639   - QPDFObjectHandle obj = getRoot();
640   - if (obj.hasKey("/Extensions")) {
641   - obj = obj.getKey("/Extensions");
642   - if (obj.isDictionary() && obj.hasKey("/ADBE")) {
643   - obj = obj.getKey("/ADBE");
644   - if (obj.isDictionary() && obj.hasKey("/ExtensionLevel")) {
645   - obj = obj.getKey("/ExtensionLevel");
646   - if (obj.isInteger()) {
647   - result = obj.getIntValueAsInt();
648   - }
649   - }
650   - }
  638 + if (Integer ExtensionLevel = getRoot()["/Extensions"]["/ADBE"]["/ExtensionLevel"]) {
  639 + int result = ExtensionLevel;
  640 + return result;
651 641 }
652   - return result;
  642 + return 0;
653 643 }
654 644  
655 645 QPDFObjectHandle
... ...