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.
This commit is contained in:
Jonas Jenwald 2025-04-30 15:26:00 +02:00
parent b8de9a372f
commit 254431df1e

View File

@ -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) {