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 { PipelineData::ExternalStream {
stdout: Some(s), .. stdout: Some(s), ..
} => { } => {
let mut items = vec![]; let mut output = String::new();
for val in s { for val in s {
match val { match val {
Ok(val) => { Ok(val) => match val.as_string() {
items.push(val);
}
Err(e) => {
return Err(e);
}
}
}
let mut output = String::new();
for item in items {
match item.as_string() {
Ok(s) => output.push_str(&s), Ok(s) => output.push_str(&s),
Err(err) => { Err(err) => return Err(err),
return Err(err); },
Err(e) => return Err(e),
} }
} }
}
Ok(output) Ok(output)
} }
} }