From 0655e5b1c466ddb64a26e866fd36addff5c7a55c Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Sat, 26 Nov 2022 23:29:19 +0100 Subject: [PATCH] Add performance note about prism scopes --- .../dataverse/src/derivations/prism/prism.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/dataverse/src/derivations/prism/prism.ts b/packages/dataverse/src/derivations/prism/prism.ts index 121119c..e12b342 100644 --- a/packages/dataverse/src/derivations/prism/prism.ts +++ b/packages/dataverse/src/derivations/prism/prism.ts @@ -106,20 +106,20 @@ export class PrismDerivation extends AbstractDerivation { class PrismScope { isPrismScope = true - private _subs: Record = {} + + // NOTE probably not a great idea to eager-allocate all of these objects/maps for every scope, + // especially because most wouldn't get used in the majority of cases. However, back when these + // were stored on weakmaps, they were uncomfortable to inspect in the debugger. + readonly subs: Record = {} readonly effects: Map = new Map() readonly memos: Map = new Map() readonly refs: Map> = new Map() sub(key: string) { - if (!this._subs[key]) { - this._subs[key] = new PrismScope() + if (!this.subs[key]) { + this.subs[key] = new PrismScope() } - return this._subs[key] - } - - get subs() { - return this._subs + return this.subs[key] } cleanupEffects() {