Skip to content

Commit

Permalink
Memoize buildNamespaceMap
Browse files Browse the repository at this point in the history
  • Loading branch information
dabbott committed Dec 15, 2023
1 parent ceca333 commit 2db855a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/noya-compiler/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DesignSystemDefinition } from '@noya-design-system/protocol';
import { memoize } from 'noya-utils';

const passthroughSymbol = Symbol('passthrough');
const simpleElementSymbol = Symbol('simpleElement');
Expand Down Expand Up @@ -65,7 +66,9 @@ export type NamespaceItem = {
accessPath?: string[];
};

export function buildNamespaceMap(imports: DesignSystemDefinition['imports']) {
export const buildNamespaceMap = memoize(function buildNamespaceMap(
imports: DesignSystemDefinition['imports'],
) {
const namespaceMap = new Map<unknown, NamespaceItem>();

for (const declaration of imports ?? []) {
Expand All @@ -85,4 +88,4 @@ export function buildNamespaceMap(imports: DesignSystemDefinition['imports']) {
}

return namespaceMap;
}
});

0 comments on commit 2db855a

Please sign in to comment.