Skip to content

Commit d35663b

Browse files
perf: avoid redundant setItem call if flagSetCache has not changed
1 parent ec15d2c commit d35663b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
206206
const flagSetFromStorage = this.storage.getItem(flagSetKey);
207207

208208
const flagSetCache = new Set(flagSetFromStorage ? JSON.parse(flagSetFromStorage) : []);
209+
210+
if (flagSetCache.has(featureFlag.name)) return;
211+
209212
flagSetCache.add(featureFlag.name);
210213

211214
this.storage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));

0 commit comments

Comments
 (0)