diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 89d1ec59a36..a5ba80be2cb 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -490,11 +490,13 @@ 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. + write_slow(handle, stdout) +} + +#[cfg_attr(any(target_os = "linux", target_os = "android"), inline(never))] // splice fast-path does not require this allocation +#[cfg_attr(not(any(target_os = "linux", target_os = "android")), inline)] +fn write_slow(handle: &mut InputHandle, stdout: io::Stdout) -> CatResult<()> { 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) {