Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(commands): swap shell output as_ref + clone with take #10983

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
perf(commands): swap as_ref + clone with take
Current `as_ref` + `clone` combo is just to deal with lifetime issues of
the loop. Instead, `take` can take ownership directly, removing
unnecessary operations. This can improve performance for particularly
large shell output
  • Loading branch information
RoloEdits committed Jun 18, 2024
commit 104835fe3c944837bbac224580e1e41e19b72f5f
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5754,8 +5754,8 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
let mut shell_output: Option<Tendril> = None;
let mut offset = 0isize;
for range in selection.ranges() {
let output = if let Some(output) = shell_output.as_ref() {
output.clone()
let output = if let Some(output) = shell_output.take() {
output
} else {
let fragment = range.slice(text);
match shell_impl(shell, cmd, pipe.then(|| fragment.into())) {
Expand Down
Loading