Skip to content

Commit a4aaadc

Browse files
committed
tee: avoid unnecessarily cloning argument list
1 parent fd4301d commit a4aaadc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/uu/tee/src/tee.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ fn tee(options: &Options) -> Result<()> {
148148
}
149149
let mut writers: Vec<NamedWriter> = options
150150
.files
151-
.clone()
152-
.into_iter()
151+
.iter()
153152
.filter_map(|file| open(file, options.append, options.output_error.as_ref()))
154153
.collect::<Result<Vec<NamedWriter>>>()?;
155154
let had_open_errors = writers.len() != options.files.len();
@@ -188,11 +187,11 @@ fn tee(options: &Options) -> Result<()> {
188187
/// If that error should lead to program termination, this function returns Some(Err()),
189188
/// otherwise it returns None.
190189
fn open(
191-
name: String,
190+
name: &str,
192191
append: bool,
193192
output_error: Option<&OutputErrorMode>,
194193
) -> Option<Result<NamedWriter>> {
195-
let path = PathBuf::from(name.clone());
194+
let path = PathBuf::from(name);
196195
let mut options = OpenOptions::new();
197196
let mode = if append {
198197
options.append(true)
@@ -202,7 +201,7 @@ fn open(
202201
match mode.write(true).create(true).open(path.as_path()) {
203202
Ok(file) => Some(Ok(NamedWriter {
204203
inner: Box::new(file),
205-
name,
204+
name: name.to_owned(),
206205
})),
207206
Err(f) => {
208207
show_error!("{}: {}", name.maybe_quote(), f);

0 commit comments

Comments
 (0)