Merge pull request #3104 from cciollaro/fix/scan-deep-watch-performance

perf(scan): replace deep watch with computed to reduce reactivity overhead
This commit is contained in:
Georges-Antoine Assi
2026-03-09 21:45:19 -04:00
committed by GitHub

View File

@@ -90,16 +90,18 @@ watch(metadataOptions, (newOptions) => {
);
});
// Adding each new scanned platform to panelIndex to be open by default
watch(
scanningPlatforms,
() => {
panels.value = scanningPlatforms.value
.map((p, index) => (p.roms.length > 0 ? index : -1))
.filter((index) => index !== -1);
},
{ deep: true },
// Track which platforms have ROMs without a deep watch on the entire array.
// The computed returns a stable string that only changes when a platform
// transitions from 0→>0 ROMs (or back), so the watch fires O(n_platforms)
// times rather than O(n_roms) times.
const platformsWithRomsKey = computed(() =>
scanningPlatforms.value.map((p) => (p.roms.length > 0 ? 1 : 0)).join(""),
);
watch(platformsWithRomsKey, () => {
panels.value = scanningPlatforms.value
.map((p, index) => (p.roms.length > 0 ? index : -1))
.filter((index) => index !== -1);
});
const scanOptions = [
{