From e823c27c8d63497bd2f815630bb04b7c61970e7e Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 20 Feb 2024 15:51:32 +0100 Subject: [PATCH] Only GetGlobals when we actually need them (#7855) Since we only need it as a backup if accountVaultTimeoutAction is null/undefined, there should be no need to call this function every time. While the overhead may seem trivial at first glance, it can add up to a massive increase in runtime when the function is called repeatedly in quick succession (e.g. when running `bw list items` where it is executed once for every item). In my concrete case this change leads to a 20x speedup. --- libs/common/src/platform/services/state.service.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/common/src/platform/services/state.service.ts b/libs/common/src/platform/services/state.service.ts index 7a3d5c471c..6a9abf2be0 100644 --- a/libs/common/src/platform/services/state.service.ts +++ b/libs/common/src/platform/services/state.service.ts @@ -2235,10 +2235,14 @@ export class StateService< const accountVaultTimeoutAction = ( await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())) )?.settings?.vaultTimeoutAction; - const globalVaultTimeoutAction = ( - await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())) - )?.vaultTimeoutAction; - return accountVaultTimeoutAction ?? globalVaultTimeoutAction; + return ( + accountVaultTimeoutAction ?? + ( + await this.getGlobals( + this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()), + ) + )?.vaultTimeoutAction + ); } async setVaultTimeoutAction(value: string, options?: StorageOptions): Promise {