From 6c6f988f3ce06a43411c5bcaa46ecf041047fc31 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 9 Aug 2024 14:41:26 +0200 Subject: [PATCH] Performance: don't clone objects when saving them to the IDB --- src/Logic/Web/IdbLocalStorage.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Logic/Web/IdbLocalStorage.ts b/src/Logic/Web/IdbLocalStorage.ts index ec417a1f8d..9411d1e3b6 100644 --- a/src/Logic/Web/IdbLocalStorage.ts +++ b/src/Logic/Web/IdbLocalStorage.ts @@ -10,7 +10,7 @@ export class IdbLocalStorage { public static Get( key: string, - options?: { defaultValue?: T; whenLoaded?: (t: T | null) => void } + options?: { defaultValue?: T; whenLoaded?: (t: T | null) => void }, ): UIEventSource { if (IdbLocalStorage._sourceCache[key] !== undefined) { return IdbLocalStorage._sourceCache[key] @@ -39,11 +39,14 @@ export class IdbLocalStorage { } public static SetDirectly(key: string, value: any): Promise { - const copy = Utils.Clone(value) - return idb.set(key, copy) + return idb.set(key, value) } static GetDirectly(key: string): Promise { return idb.get(key) } + + static clearAll() { + return idb.clear() + } }