cat: avoid unnecessary allocation

This commit is contained in:
oech3
2026-04-12 16:31:52 +02:00
committed by Sylvestre Ledru
parent 9f50c8b42e
commit efd0f0cd10
+4
View File
@@ -489,6 +489,10 @@ fn write_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
// If we're not on Linux or Android, or the splice() call failed,
// fall back on slower writing.
let mut stdout_lock = stdout.lock();
// stack allocation is overhead when splice succeed
#[cfg(any(target_os = "linux", target_os = "android"))]
let mut buf = vec![0; 1024 * 64];
#[cfg(not(any(target_os = "linux", target_os = "android")))]
let mut buf = [0; 1024 * 64];
loop {
match handle.reader.read(&mut buf) {