From 74c1795c9f814a58ebc390ba67032f7c3e712d33 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 2 Jan 2025 15:09:19 +0100 Subject: [PATCH] Use `Dict` iteration more (PR 19051 follow-up) There's a few cases where we're looping through the result of `Dict.prototype.getKeys` and then manually look-up the values, which after PR 19051 can be replaced with direct iteration instead. --- src/core/catalog.js | 3 +-- src/core/document.js | 4 +--- src/core/evaluator.js | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core/catalog.js b/src/core/catalog.js index a38be8f9a9988..b2f0d8711f51a 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -923,8 +923,7 @@ class Catalog { } let prefs = null; - for (const key of obj.getKeys()) { - const value = obj.get(key); + for (const [key, value] of obj) { let prefValue; switch (key) { diff --git a/src/core/document.js b/src/core/document.js index 1744066d1d625..7d9860b851dae 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1472,9 +1472,7 @@ class PDFDocument { return shadow(this, "documentInfo", docInfo); } - for (const key of infoDict.getKeys()) { - const value = infoDict.get(key); - + for (const [key, value] of infoDict) { switch (key) { case "Title": case "Author": diff --git a/src/core/evaluator.js b/src/core/evaluator.js index f22f75a8bfa02..fb80032f5adf2 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1133,8 +1133,7 @@ class PartialEvaluator { // This array holds the converted/processed state data. const gStateObj = []; let promise = Promise.resolve(); - for (const key of gState.getKeys()) { - const value = gState.get(key); + for (const [key, value] of gState) { switch (key) { case "Type": break;