Skip to content

⚡ Bolt: Optimize Map lookups by removing Array.from().find() allocations#91

Open
subsubl wants to merge 1 commit intomasterfrom
bolt-map-lookup-optimization-8288941553653549021
Open

⚡ Bolt: Optimize Map lookups by removing Array.from().find() allocations#91
subsubl wants to merge 1 commit intomasterfrom
bolt-map-lookup-optimization-8288941553653549021

Conversation

@subsubl
Copy link
Copy Markdown
Owner

@subsubl subsubl commented Apr 12, 2026

💡 What

Replaced the use of Array.from(filesMap.value.entries()).find(...) with a for...of loop in pages/builder.vue when searching for specific files (like appinfo.spixi and icon.png) in a case-insensitive manner.

🎯 Why

Converting an entire Map's entries into an array just to find a single entry is an anti-pattern. Array.from() eagerly allocates a new array in memory, resulting in an O(N) operation in terms of both space and time. By using a standard for...of loop over filesMap.value.entries(), we avoid the unnecessary array allocation and garbage collection pressure, while also benefiting from short-circuiting (the loop breaks as soon as the target file is found).

📊 Impact

  • Memory: Eliminates O(N) temporary array allocations per file lookup, reducing GC overhead.
  • Speed: Reduces search time from strict O(N) (plus array creation overhead) to an average of O(N/2) (early exit), improving packing logic efficiency for larger app folders.

🔬 Measurement

The change is localized to validateFiles and packApp inside pages/builder.vue. You can verify this by dragging/dropping or selecting a folder containing appinfo.spixi and icon.png in the Mini App Packer UI at /builder. The file processing logic will function exactly as before but with reduced overhead. The project still successfully compiles with pnpm build.


PR created automatically by Jules for task 8288941553653549021 started by @subsubl

Replaces inefficient Map entry searches in pages/builder.vue that converted the entire Map to an array using Array.from() just to use .find(). The replacement uses a for...of loop, preventing O(N) array allocation, reducing garbage collection pressure, and enabling early exit upon finding a match.

Co-authored-by: subsubl <114085822+subsubl@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant