Simplify and reduce allocations in pipeline data loop (#6790)

This commit is contained in:
Dan Davison 2022-10-20 06:22:07 -04:00 committed by GitHub
parent 7336e1df1a
commit 50e53e788a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,29 +185,17 @@ impl PipelineData {
PipelineData::ExternalStream {
stdout: Some(s), ..
} => {
let mut items = vec![];
let mut output = String::new();
for val in s {
match val {
Ok(val) => {
items.push(val);
}
Err(e) => {
return Err(e);
}
Ok(val) => match val.as_string() {
Ok(s) => output.push_str(&s),
Err(err) => return Err(err),
},
Err(e) => return Err(e),
}
}
let mut output = String::new();
for item in items {
match item.as_string() {
Ok(s) => output.push_str(&s),
Err(err) => {
return Err(err);
}
}
}
Ok(output)
}
}