From 64288da32ef7613a42d8f6f09272e1d05492a2d1 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:40:04 +0900 Subject: [PATCH] cat: avoid unnecessary allocation --- src/uu/cat/src/cat.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index a572e56d25a..f9916ef4014 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -489,6 +489,10 @@ fn write_fast(handle: &mut InputHandle) -> 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) {