perf(stdin): avoid unnecessary allocations when streaming from stdin (#475)

This commit is contained in:
Alexandre Pasmantier 2025-04-20 23:11:02 +02:00 committed by GitHub
parent 433d7fa270
commit ce02824f3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -77,10 +77,10 @@ fn stream_from_stdin(injector: &Injector<String>) {
loop {
match stdin.read_line(&mut buffer) {
Ok(c) if c > 0 => {
let buf = buffer.trim();
if !buf.is_empty() {
injector.push(buf.to_string(), |e, cols| {
cols[0] = e.to_string().into();
let trimmed = buffer.trim();
if !trimmed.is_empty() {
injector.push(trimmed.to_owned(), |e, cols| {
cols[0] = e.clone().into();
});
}
buffer.clear();