From 662bd022cefaa591a454f68faaac5010309e628a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 8 Oct 2024 12:24:09 +0200 Subject: [PATCH] Reduce duplication in the `PDFDocument.calculationOrderIds` getter --- src/core/document.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 723c016e2..2dab34d06 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1947,12 +1947,7 @@ class PDFDocument { } get calculationOrderIds() { - const acroForm = this.catalog.acroForm; - if (!acroForm?.has("CO")) { - return shadow(this, "calculationOrderIds", null); - } - - const calculationOrder = acroForm.get("CO"); + const calculationOrder = this.catalog.acroForm?.get("CO"); if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) { return shadow(this, "calculationOrderIds", null); } @@ -1963,10 +1958,7 @@ class PDFDocument { ids.push(id.toString()); } } - if (ids.length === 0) { - return shadow(this, "calculationOrderIds", null); - } - return shadow(this, "calculationOrderIds", ids); + return shadow(this, "calculationOrderIds", ids.length ? ids : null); } get annotationGlobals() {