From efd0f0cd10c73d82bfc35be1532820c79f13fc4e 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 a572e56d2..f9916ef40 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) {