Skip to content

Commit ea6f3fb

Browse files
committed
perf: avoid array allocation in live ROM lookup
Generated-By: PostHog Code Task-Id: b131c873-6e03-47dd-bf51-c99f01ef1f5f
1 parent 807ae86 commit ea6f3fb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

frontend/src/v2/stores/galleryRoms.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,13 @@ export default defineStore("v2GalleryRoms", {
230230

231231
/** Add a ROM announced by the scan socket to the active gallery. */
232232
addLiveRom(rom: SimpleRom) {
233-
const existingPosition = [...this.byPosition.entries()].find(
234-
([, existing]) => existing.id === rom.id,
235-
)?.[0];
233+
let existingPosition: number | undefined;
234+
for (const [position, existing] of this.byPosition) {
235+
if (existing.id === rom.id) {
236+
existingPosition = position;
237+
break;
238+
}
239+
}
236240
if (existingPosition !== undefined) {
237241
this.byPosition.set(existingPosition, rom);
238242
return;

0 commit comments

Comments
 (0)