Skip to content

refactor(file-browser): Replace plain object directory cache with Map - #2831

Merged
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:perf/fb-dir-cache-map
Aug 29, 2026
Merged

refactor(file-browser): Replace plain object directory cache with Map#2831
bajrangCoder merged 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:perf/fb-dir-cache-map

Conversation

@AuDevTist1C

Copy link
Copy Markdown
Contributor

Replaces the plain object ({}) used for directory caching (cachedDir) in src/pages/fileBrowser/fileBrowser.js with an ES6 Map instance.

Motivation

  • Key Safety: Plain objects inherit properties from Object.prototype, which can lead to collisions or unexpected behavior if file paths match built-in property names. Map provides clean key isolation.

References


Summary of Code Changes

  • src/pages/fileBrowser/fileBrowser.js:
    • Initialized cachedDir variable using new Map().
    • Replaced url in cachedDir with cachedDir.has(url).
    • Replaced cachedDir[url] access with cachedDir.get(url).
    • Replaced property assignment cachedDir[dir.url] = dir with cachedDir.set(dir.url, dir).
    • Replaced property deletion delete cachedDir[url] with native cachedDir.delete(url).

(PR name and description are AI generated (Gemini 3.6 flash))

Replace the plain object container used for cached directories with an ES6 `Map` to improve 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)
@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Replaces the file browser’s plain-object directory cache with an ES6 Map.

  • Converts cache initialization, lookup, insertion, deletion, and scroll-state access to Map APIs.
  • Removes redundant invalidation from the reload action because reload() already deletes the current cache entry.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

All directory-cache operations consistently use Map, the cache remains closure-local, and every reload continues to invalidate the current directory before navigating and rereading it.

Important Files Changed

Filename Overview
src/pages/fileBrowser/fileBrowser.js The directory-cache conversion is complete and preserves cache lookup, invalidation, reload, and scroll-restoration behavior.

Reviews (1): Last reviewed commit: "refactor(file-browser): Convert director..." | Re-trigger Greptile

@bajrangCoder
bajrangCoder added this pull request to the merge queue Aug 29, 2026
Merged via the queue into Acode-Foundation:main with commit 7357c01 Aug 29, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Aug 29, 2026
@AuDevTist1C
AuDevTist1C deleted the perf/fb-dir-cache-map branch August 29, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants