Skip to content

Commit

Permalink
Remove unnecessary clones when piping commands in hull (#1089)
Browse files Browse the repository at this point in the history
* Commands can take ownership of `previous_output` as they then overwrite it anyway.

* The final command can take ownership of all streams.

---------

Co-authored-by: Poxxy <41162160+Poxxy@users.noreply.github.com>
Co-authored-by: Klim Tsoutsman <klim@tsoutsman.com>
  • Loading branch information
3 people committed Jan 4, 2024
1 parent 813015b commit ffb5e8b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions applications/hull/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ impl Shell {
return result.map(|_| None);
} else {
let streams = IoStreams {
// TODO: Technically clone not needed.
stdin: previous_output.clone(),
stdout: shell_streams.stdout.clone(),
stderr: stderr.clone(),
stdin: previous_output,
stdout: shell_streams.stdout,
stderr,
discipline: shell_streams.discipline,
};
let part = self.resolve_external(command, args, streams, job_id)?;
Expand All @@ -204,7 +203,7 @@ impl Shell {

let pipe = Stdio::new();
let streams = IoStreams {
stdin: previous_output.clone(),
stdin: previous_output,
stdout: Arc::new(pipe.get_writer()),
stderr: stderr.clone(),
discipline: None,
Expand Down

0 comments on commit ffb5e8b

Please sign in to comment.