Skip to content

Commit 254431d

Browse files
committed
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.
1 parent b8de9a3 commit 254431d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/core/catalog.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ class Catalog {
691691
}
692692

693693
getDestination(id) {
694+
// Avoid extra lookup/parsing when all destinations are already available.
695+
if (this.hasOwnProperty("destinations")) {
696+
return this.destinations[id] ?? null;
697+
}
698+
694699
const rawDests = this.#readDests();
695700
for (const obj of rawDests) {
696701
if (obj instanceof NameTree || obj instanceof Dict) {

0 commit comments

Comments
 (0)