⚡ Bolt: Optimize push_tab_to_leaf heap allocations - #373
Conversation
…as reference Passes `new_tab_id` as `&str` instead of `String` to prevent redundant heap allocations during the `.any()` tree traversal inside `push_tab_to_leaf`. The string is now only allocated exactly once (via `.to_string()`) when the target insertion point is actually found. Co-authored-by: Lucenx9 <185146821+Lucenx9@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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe tab insertion path now passes the new surface ID by reference through pane-tree traversal and converts it to an owned string only when inserting into a leaf. ChangesTab ID borrowing
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
💡 What:
Optimized
push_tab_to_leafincrates/forktty-core/src/model/pane_tree.rsto takenew_tab_idas a string slice reference (&str) rather than an owned string (String/SurfaceId). The caller inmodel.rswas updated to pass a reference instead of unconditionally cloningnew_id.🎯 Why:
During pane tree operations that insert new tabs,
push_tab_to_leafrecursively traversesPaneNode::Splitnodes using an.any()iterator closure. Previously, thenew_tab_idstring was cloned on every single recursive call during this traversal, leading to O(N) unnecessary heap allocations where N is the number of child splits traversed.📊 Impact:
Significantly reduces redundant
Stringallocations during tab creation or moving operations within complex workspaces, especially when navigating deep split hierarchies. The string allocation is completely deferred until the precise target leaf is discovered and the push operation is imminent.🔬 Measurement:
Tested and verified via
cargo check -p forktty-coreandcargo test -p forktty-core. The optimization strictly preserves existing behavior while improving execution speed and memory efficiency.PR created automatically by Jules for task 6611019296646207069 started by @Lucenx9
cargo check -p forktty-coreandcargo test -p forktty-core.