From 254431df1e6b22eed9a93c202759bd2e87a9f566 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 30 Apr 2025 15:26:00 +0200 Subject: [PATCH] Avoid extra lookup/parsing when all destinations are already available Whenever we cannot find a destination we'll fallback to checking all destinations, to account for e.g. out-of-order NameTrees, and in those cases any subsequent destination-lookups can be made a tiny bit more efficient by immediately checking the already cached destinations. --- src/core/catalog.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/catalog.js b/src/core/catalog.js index 6245bfae3..9e2d08474 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -691,6 +691,11 @@ class Catalog { } getDestination(id) { + // Avoid extra lookup/parsing when all destinations are already available. + if (this.hasOwnProperty("destinations")) { + return this.destinations[id] ?? null; + } + const rawDests = this.#readDests(); for (const obj of rawDests) { if (obj instanceof NameTree || obj instanceof Dict) {