Skip to content

Commit 44324cc

Browse files
committed
Remove allowEviction
1 parent 2b385a4 commit 44324cc

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

packages/browser/src/utils/featureFlags.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@ export function insertFlagToScope(name: string, value: unknown, maxSize: number
7373
* @param name Name of the feature flag to insert.
7474
* @param value Value of the feature flag.
7575
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
76-
* @param allowEviction If true, the oldest flag is evicted when the buffer is full. Otherwise the new flag is dropped.
7776
*/
7877
export function insertToFlagBuffer(
7978
flags: FeatureFlag[],
8079
name: string,
8180
value: unknown,
8281
maxSize: number,
83-
allowEviction: boolean = true,
8482
): void {
8583
if (typeof value !== 'boolean') {
8684
return;
@@ -100,12 +98,8 @@ export function insertToFlagBuffer(
10098
}
10199

102100
if (flags.length === maxSize) {
103-
if (allowEviction) {
104-
// If at capacity, pop the earliest flag - O(n)
105-
flags.shift();
106-
} else {
107-
return;
108-
}
101+
// If at capacity, pop the earliest flag - O(n)
102+
flags.shift();
109103
}
110104

111105
// Push the flag to the end - O(1)

packages/browser/test/utils/featureFlags.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,6 @@ describe('flags', () => {
5959
]);
6060
});
6161

62-
it('drops new entries when allowEviction is false and buffer is full', () => {
63-
const buffer: FeatureFlag[] = [];
64-
const maxSize = 0;
65-
insertToFlagBuffer(buffer, 'feat1', true, maxSize, false);
66-
insertToFlagBuffer(buffer, 'feat2', true, maxSize, false);
67-
insertToFlagBuffer(buffer, 'feat3', true, maxSize, false);
68-
69-
expect(buffer).toEqual([]);
70-
});
71-
72-
it('still updates order and values when allowEviction is false and buffer is full', () => {
73-
const buffer: FeatureFlag[] = [];
74-
const maxSize = 1;
75-
insertToFlagBuffer(buffer, 'feat1', false, maxSize, false);
76-
insertToFlagBuffer(buffer, 'feat1', true, maxSize, false);
77-
78-
expect(buffer).toEqual([{ flag: 'feat1', result: true }]);
79-
});
80-
8162
it('does not allocate unnecessary space', () => {
8263
const buffer: FeatureFlag[] = [];
8364
const maxSize = 1000;

0 commit comments

Comments
 (0)