Skip to content

Commit 1aca78e

Browse files
Fix code scanning alert no. 81: Prototype-polluting assignment
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent d0e5207 commit 1aca78e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/core/src/state/GCPolicy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Controller from '../controller/Controller.js';
55

66
export class GCPolicy implements GCInterface {
77
protected endpointCount: Record<string, number> = {};
8-
protected entityCount: Record<string, Record<string, number>> = {};
8+
protected entityCount: Map<string, Map<string, number>> = new Map();
99
protected endpoints = new Set<string>();
1010
protected entities: EntityPath[] = [];
1111
declare protected intervalId: ReturnType<typeof setInterval>;
@@ -41,9 +41,9 @@ export class GCPolicy implements GCInterface {
4141
this.endpointCount[key]++;
4242
paths.forEach(path => {
4343
if (!(path.key in this.endpointCount)) {
44-
this.entityCount[path.key] = {};
44+
this.entityCount.set(path.key, new Map());
4545
}
46-
this.entityCount[path.key][path.pk]++;
46+
this.entityCount.get(path.key)!.set(path.pk, (this.entityCount.get(path.key)!.get(path.pk) || 0) + 1);
4747
});
4848

4949
// decrement
@@ -57,7 +57,7 @@ export class GCPolicy implements GCInterface {
5757
if (!(path.key in this.endpointCount)) {
5858
return;
5959
}
60-
this.entityCount[path.key][path.pk]--;
60+
this.entityCount.get(path.key)!.set(path.pk, this.entityCount.get(path.key)!.get(path.pk)! - 1);
6161
});
6262
};
6363
};

0 commit comments

Comments
 (0)