Skip to content

⚡ Bolt: [performance improvement] Optimize FileList.jsx render loop complexity - #27

Open
TheerasakPing wants to merge 2 commits into
mainfrom
bolt-filelist-optimization-12768537958252469048
Open

TheerasakPing wants to merge 2 commits into
mainfrom
bolt-filelist-optimization-12768537958252469048

Conversation

@TheerasakPing

Copy link
Copy Markdown
Owner

💡 What:
Optimized the render loop in FileList.jsx by replacing O(M) Array.prototype.some searches inside the .map iteration with O(1) Set.has lookups. Created selectedPaths and cutPaths Sets memoized via useMemo.

🎯 Why:
For each item in sortedItems (N), the component was iterating through selectedItems (M1) and clipboard.items (M2). This created an O(N * (M1+M2)) complexity during the critical render phase, causing noticeable frame drops and slow interactions when navigating directories with hundreds or thousands of files with many files selected.

📊 Impact:
Reduces the computational complexity of rendering the file list from O(N*M) to O(N). This makes rendering virtually constant time with respect to the number of selected/cut items, eliminating UI jank when selecting multiple files in large directories.

🔬 Measurement:

  1. Open a directory with 1000+ files.
  2. Select 100+ items.
  3. Observe React Profiler commit times during selection updates. Before this change, the FileList render time scaled linearly with selection size. After this change, it scales only with the visible/total items length.

PR created automatically by Jules for task 12768537958252469048 started by @TheerasakPing

…omplexity

Refactor O(N*M) array iteration lookups into O(N) Set lookups during render loop.

Co-authored-by: TheerasakPing <185220419+TheerasakPing@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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.

Added `use crate::log_info;` to tests mod in `src-tauri/src/commands/volume_operations_commands.rs` to fix macro resolution during cargo test.

Co-authored-by: TheerasakPing <185220419+TheerasakPing@users.noreply.github.com>
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