Skip to content

Commit f60ba1c

Browse files
committed
fix: made type-metadata.storage.ts much faster
Changed the data modeling of type-metadata storage to store the data in maps instead of arrays. This results in a dramatic improvement of application startup time since many of the lookups for metadata are now in O(1) instead of O(n)
1 parent 1589d6d commit f60ba1c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/graphql/lib/schema-builder/collections/array.collection.ts renamed to packages/graphql/lib/schema-builder/collections/array-with-global-cache.collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export class ArrayCollection<T> {
1+
export class ArrayWithGlobalCacheCollection<T> {
22
private readonly array: T[] = [];
33

44
constructor(private globalArray: Array<T>) {}

packages/graphql/lib/schema-builder/collections/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './metadata.storage.collection.list';
22
export * from './field-directive.collection';
3-
export * from './array.collection';
3+
export * from './array-with-global-cache.collection';
44
export * from './metada.collection.model.interface';
55
export * from './metadata-by-name.collection';
66
export * from './metadata-list-by-name.collection';

packages/graphql/lib/schema-builder/collections/metadata.storage.collection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { MetadataListByNameCollection } from './metadata-list-by-name.collection';
1212
import { FieldDirectiveCollection } from './field-directive.collection';
1313
import { ObjectTypeMetadata } from '../metadata/object-type.metadata';
14-
import { ArrayCollection } from './array.collection';
14+
import { ArrayWithGlobalCacheCollection } from './array-with-global-cache.collection';
1515
import { MetadataCollectionModelInterface } from './metada.collection.model.interface';
1616

1717
export class MetadataStorageCollection {
@@ -24,10 +24,10 @@ export class MetadataStorageCollection {
2424
new MetadataListByNameCollection<PropertyExtensionsMetadata>(
2525
this.all.fieldExtensions,
2626
);
27-
classDirectives = new ArrayCollection<ClassDirectiveMetadata>(
27+
classDirectives = new ArrayWithGlobalCacheCollection<ClassDirectiveMetadata>(
2828
this.all.classDirectives,
2929
);
30-
classExtensions = new ArrayCollection<ClassExtensionsMetadata>(
30+
classExtensions = new ArrayWithGlobalCacheCollection<ClassExtensionsMetadata>(
3131
this.all.classExtensions,
3232
);
3333

0 commit comments

Comments
 (0)