perf: ⚡ Bolt: avoid allocating joined strings in sort_by#106
perf: ⚡ Bolt: avoid allocating joined strings in sort_by#106
Conversation
Replaces `.join(", ")` inside `sort_by` loops with a direct lexicographical
comparison of `Vec<String>`. Doing this drops expensive string allocations
(and multiple iterations over the slices to build the string) that previously
caused O(N log N) hidden heap allocations during the hot loop in TUI rendering.
Co-authored-by: damacus <40786+damacus@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. |
Replaces `.join(", ")` inside `sort_by` loops with a direct lexicographical
comparison of `Vec<String>`. Doing this drops expensive string allocations
(and multiple iterations over the slices to build the string) that previously
caused O(N log N) hidden heap allocations during the hot loop in TUI rendering.
Also derives `Default` on `RunnerDiscoveryMode` to fix a clippy warning.
Co-authored-by: damacus <40786+damacus@users.noreply.github.com>
💡 What: Removed
.join(", ")calls insidesort_byfor comparing runner tags and replaced it with a directVeclexicographical.cmp().🎯 Why: Creating new, dynamically allocated Strings for every comparison step within a generic sorting loop creates hidden O(N log N) heap allocations. Because the sorting occurs dynamically when computing application view state, these allocations cause avoidable lag and heap fragmentation.
📊 Impact: Removes unnecessary allocation spikes during frequent re-renders and re-sorts, significantly improving the framerate consistency when the tags sort is active.
🔬 Measurement: Use the
bhotkey in settings to run local benchmarks (or monitor memory allocation/lag while scrolling/sorting).PR created automatically by Jules for task 1502315767318017684 started by @damacus