Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/uu/wc/src/count_fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
// - sender without splice is bottleneck of our wc -c
loop {
match splice(fd, &null_file, MAX_ROOTLESS_PIPE_SIZE) {
Ok(0) => break,
Ok(0) => return Ok(byte_count),
Ok(res) => byte_count += res,
Err(_) => return Err(byte_count),
}
Expand All @@ -57,7 +57,7 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
// input is not pipe. needs broker to use splice() with additional cost
loop {
match splice(fd, &pipe_wr, MAX_ROOTLESS_PIPE_SIZE) {
Ok(0) => break,
Ok(0) => return Ok(byte_count),
Ok(res) => {
byte_count += res;
splice_exact(&pipe_rd, &null_file, res).map_err(|_| byte_count)?;
Expand All @@ -66,10 +66,8 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
}
}
} else {
return Ok(0_usize);
Err(0)
}

Ok(byte_count)
}

/// In the special case where we only need to count the number of bytes. There
Expand Down
Loading