From 75113e45179aa41f495f9d061cd72ac98ed70385 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald <jonas.jenwald@gmail.com> Date: Fri, 4 Jun 2021 20:53:17 +0200 Subject: [PATCH] Initialize `HTMLResult.{FAILURE, EMPTY}` lazily While these objects aren't exactly that big and/or complex, they are nonetheless *only* necessary for XFA documents. However, currently these objects are initialized *eagerly* for all PDF documents. By using the same pattern as elsewhere in the code-base, it's very easy to make these lazily initialized; so let's just do that instead :-) --- src/core/xfa/utils.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/xfa/utils.js b/src/core/xfa/utils.js index 585ed5464..ab88aa88a 100644 --- a/src/core/xfa/utils.js +++ b/src/core/xfa/utils.js @@ -13,6 +13,8 @@ * limitations under the License. */ +import { shadow } from "../../shared/util.js"; + const dimConverters = { pt: x => x, cm: x => (x / 2.54) * 72, @@ -165,6 +167,14 @@ function getBBox(data) { } class HTMLResult { + static get FAILURE() { + return shadow(this, "FAILURE", new HTMLResult(false, null, null)); + } + + static get EMPTY() { + return shadow(this, "EMPTY", new HTMLResult(true, null, null)); + } + constructor(success, html, bbox) { this.success = success; this.html = html; @@ -176,9 +186,6 @@ class HTMLResult { } } -HTMLResult.FAILURE = new HTMLResult(false, null, null); -HTMLResult.EMPTY = new HTMLResult(true, null, null); - export { getBBox, getColor,