From 2d1176965c8aa65c185823b36bd96c5ae2730bda Mon Sep 17 00:00:00 2001 From: arryndoestech <178195651+arryndoestech@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:45:25 +0200 Subject: [PATCH] fix: optimize file lookup for large folders Replaced the previous O(N^2) file lookup with one that: 1. Builds the map of the files with the path 2. Iterates over the sorted nodes and retrieves each file from the map This turns the O(N^2) lookup into 2 O(N) operations Tested on a folder with about 10 000 files this cuts down the time to finish enumerating fromabout 90 seconds to about 11 seconds Also fixes the browser becoming unresponsive for that time Signed-off-by: arryndoestech <178195651+arryndoestech@users.noreply.github.com> --- src/views/Viewer.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/Viewer.vue b/src/views/Viewer.vue index 809424f2a..6db9acba9 100644 --- a/src/views/Viewer.vue +++ b/src/views/Viewer.vue @@ -841,8 +841,12 @@ export default defineComponent({ sortingOrder: this.sortingConfig.asc ? 'asc' : 'desc', }) + const filesByPath = new Map( + filteredFiles.map(file => [file.filename, file]), + ) + this.fileList = sortedNodes.map(node => { - return filteredFiles.find(file => file.filename === node.path) + return filesByPath.get(node.path) }) // store current position this.currentIndex = this.fileList.findIndex(file => file.filename === fileInfo.filename)