Conversation
Replace O(N) array scans (`some`) within the `sortedItems.map` rendering loop with O(1) Set lookups. Sets are computed using `useMemo` based on `selectedItems` and `clipboard` dependencies. This avoids O(N*M) complexity when rendering large directories with multiple selections or cut items. Co-authored-by: TheerasakPing <185220419+TheerasakPing@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…I Fixes Replace O(N) array scans (`some`) within the `sortedItems.map` rendering loop with O(1) Set lookups. Sets are computed using `useMemo` based on `selectedItems` and `clipboard` dependencies. This avoids O(N*M) complexity when rendering large directories with multiple selections or cut items. Also includes fixes for Rust compilation warnings/errors detected by CI: - Added missing `crate::log_info` macro import in tests - Conditionally compiled macOS specific imports - Removed unused `tauri::Manager` import - Added `allow(unused_assignments)` to variables only used conditionally in loop structures Co-authored-by: TheerasakPing <185220419+TheerasakPing@users.noreply.github.com>
💡 What: Replaced O(N) array scans (
Array.some()) inside thesortedItems.maprendering loop inFileList.jsxwith O(1)Setlookups. TheSetobjects for selected paths and cut clipboard items are computed usinguseMemo.🎯 Why: Rendering$O(N \cdot M)$ performance bottleneck. For every item $N$ in the directory, it iterated through the entire $M$ ) and
FileListhad a classicselectedItemsarray (clipboard.itemsarray to check if the item was selected or cut. This caused severe rendering lag for large directories with many selected items.📊 Impact: Reduces rendering complexity of$O(N \cdot M)$ to $O(N + M)$ . Lookup time per item during render drops from $O(M)$ to $O(1)$ . This drastically reduces re-render times for folders with thousands of files, especially when performing multi-selection.
FileListfrom🔬 Measurement: Profile the React component tree while opening a directory with >1000 items and selecting all (
Ctrl+A/Cmd+A). The render duration forFileListwill be significantly reduced compared to the baseline.Also updated the Bolt performance journal (
.jules/bolt.md) with this critical learning regardingO(N*M)rendering anti-patterns.PR created automatically by Jules for task 2359221673569039556 started by @TheerasakPing