From cc7725388b566bcfa7f65453dfe051d828a1b13f Mon Sep 17 00:00:00 2001 From: AuDevTist1C <114492072+AuDevTist1C@users.noreply.github.com> Date: Thu, 20 Aug 2026 11:02:42 +0200 Subject: [PATCH] perf(file-browser): Convert directory cache to `Map` instance Replace the plain object container used for cached directories with an ES6 `Map` to improve key lookup operations and key management semantics. Update cached directory data structure (`src/pages/fileBrowser/fileBrowser.js`): - Re-initialize `cachedDir` variable as a `Map` - Replace object property lookups with `Map.prototype.has()` and `Map.prototype.get()` - Update cache writes to use `Map.prototype.set()` - Update directory deletion calls to use `Map.prototype.delete()` (AI generated commit message) --- src/pages/fileBrowser/fileBrowser.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pages/fileBrowser/fileBrowser.js b/src/pages/fileBrowser/fileBrowser.js index ef9c59ce2..dcb53c489 100644 --- a/src/pages/fileBrowser/fileBrowser.js +++ b/src/pages/fileBrowser/fileBrowser.js @@ -171,7 +171,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { $selectionMenuToggler.style.display = "none"; $pasteToggler.style.display = "none"; const progress = {}; - let cachedDir = {}; + let cachedDir = new Map(); let currentDir = { url: null, name: null, @@ -255,8 +255,6 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } if (action === "reload") { - const { url } = currentDir; - if (url in cachedDir) delete cachedDir[url]; reload(); return; } @@ -731,7 +729,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } recents.removeFile(url); openFolder.removeItem(url); - delete cachedDir[url]; + cachedDir.delete(url); } function updateSelectionCount($count) { @@ -1471,8 +1469,8 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { let list = []; let error = false; - if (url in cachedDir) { - return cachedDir[url]; + if (cachedDir.has(url)) { + return cachedDir.get(url); } else { if (url === "/") { list = await listAllStorages(); @@ -1807,8 +1805,8 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { const $oldList = $content.get("#list"); if ($oldList) { const { url } = currentDir; - if (url && cachedDir[url]) { - cachedDir[url].scroll = $oldList.scrollTop; + if (url && cachedDir.has(url)) { + cachedDir.get(url).scroll = $oldList.scrollTop; } $oldList.remove(); } @@ -1817,13 +1815,13 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { $list.focus(); currentDir = dir; - cachedDir[dir.url] = dir; + cachedDir.set(dir.url, dir); updatePasteToggler(); } function reload() { const { url, name } = currentDir; - delete cachedDir[url]; + cachedDir.delete(url); navigate(url, name); }