From dce89e2f67c19c4a1cada7c2c13004a9d90d03c5 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 2 Sep 2025 11:57:54 -0300 Subject: [PATCH] perf: Use io::copy for SkipBytesFilter Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/filter_plugin/skip.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/filter_plugin/skip.rs b/src/filter_plugin/skip.rs index a83b195..052c65c 100644 --- a/src/filter_plugin/skip.rs +++ b/src/filter_plugin/skip.rs @@ -1,5 +1,5 @@ use super::FilterPlugin; -use std::io::{Result, Read, Write, BufRead, Seek}; +use std::io::{Result, Read, Write, BufRead}; use crate::common::PIPESIZE; pub struct SkipBytesFilter { @@ -29,15 +29,8 @@ impl FilterPlugin for SkipBytesFilter { } } - // Copy the remaining data - let mut buffer = vec![0; PIPESIZE]; - loop { - let bytes_read = reader.read(&mut buffer)?; - if bytes_read == 0 { - break; - } - writer.write_all(&buffer[..bytes_read])?; - } + // Copy the remaining data using io::copy for efficiency + std::io::copy(reader, writer)?; Ok(()) } }