Skip to content

refactor(list, for-each): thread &[WorktreeInfo] through sort and for-each - #2389

Merged
max-sixty merged 1 commit into
mainfrom
list-worktrees-slice
Apr 22, 2026
Merged

max-sixty merged 1 commit into
mainfrom
list-worktrees-slice

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Two small follow-ups to #2383.

sort_worktrees_with_cache takes &[WorktreeInfo] instead of an owned Vec<WorktreeInfo>, cloning once when materializing the sorted output. The call site in collect::collect drops its .to_vec() — one fewer Vec<WorktreeInfo> allocation on the wt list hot path.

step_for_each holds Vec<&WorktreeInfo> rather than cloning each entry into a Vec<WorktreeInfo> — the loop only borrows (worktree_display_name(wt, ...), execute_shell_command(&wt.path, ...)), so the clone was unnecessary.

No behavior change.

This was written by Claude Code on behalf of @max-sixty

…-each

Two small follow-ups to #2383.

`sort_worktrees_with_cache` takes `&[WorktreeInfo]` instead of an owned
`Vec`, cloning once when materializing the sorted output. The call site
drops `.to_vec()`, saving a full `Vec<WorktreeInfo>` allocation on the
`wt list` hot path.

`step_for_each` holds `Vec<&WorktreeInfo>` rather than cloning into
`Vec<WorktreeInfo>` — the loop only needs to borrow.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 0c9e9c9 into main Apr 22, 2026
25 checks passed
@max-sixty
max-sixty deleted the list-worktrees-slice branch April 22, 2026 15:17
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.

2 participants