mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
cat: avoid unnecessary allocation
This commit is contained in:
@@ -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,
|
// If we're not on Linux or Android, or the splice() call failed,
|
||||||
// fall back on slower writing.
|
// fall back on slower writing.
|
||||||
let mut stdout_lock = stdout.lock();
|
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];
|
let mut buf = [0; 1024 * 64];
|
||||||
loop {
|
loop {
|
||||||
match handle.reader.read(&mut buf) {
|
match handle.reader.read(&mut buf) {
|
||||||
|
|||||||
Reference in New Issue
Block a user