Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions src/uu/dd/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ fn block(buf: &[u8], cbs: usize, sync: bool, rstat: &mut ReadStat) -> Vec<Vec<u8
// If `sync` is true and there has been at least one partial
// record read from the input, then leave the all-spaces block at
// the end. Otherwise, remove it.
if let Some(last) = blocks.last() {
if (!sync || rstat.reads_partial == 0) && last.iter().all(|&e| e == SPACE) {
blocks.pop();
}
}
let _ = blocks
.pop_if(|last| (!sync || rstat.reads_partial == 0) && last.iter().all(|&e| e == SPACE));

blocks
}
Expand Down
4 changes: 1 addition & 3 deletions src/uu/nl/src/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,7 @@ fn nl<T: Read>(reader: &mut BufReader<T>, stats: &mut Stats, settings: &Settings
break;
}

if line.last().copied() == Some(b'\n') {
line.pop();
}
let _ = line.pop_if(|byte| *byte == b'\n');

if line.is_empty() {
stats.consecutive_empty_lines += 1;
Expand Down
6 changes: 1 addition & 5 deletions src/uu/paste/src/paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ fn parse_delimiters(delimiters: &OsString) -> UResult<Box<[Box<[u8]>]>> {
}

fn remove_trailing_line_ending_byte(line_ending_byte: u8, output: &mut Vec<u8>) {
if let Some(&byte) = output.last() {
if byte == line_ending_byte {
assert_eq!(output.pop(), Some(line_ending_byte));
}
}
let _ = output.pop_if(|byte| *byte == line_ending_byte);
}

enum DelimiterState<'a> {
Expand Down
4 changes: 1 addition & 3 deletions src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ fn split_seps(data: &[u8], sep: u8) -> Vec<&[u8]> {
let predicted_capacity = data.len() / PREDICTED_LINE_LENGTH;
let mut elements = Vec::with_capacity(predicted_capacity);
elements.extend(data.split(|&b| b == sep));
if elements.last().is_some_and(|e| e.is_empty()) {
elements.pop();
}
let _ = elements.pop_if(|e| e.is_empty());
elements
}

Expand Down
4 changes: 1 addition & 3 deletions src/uu/uniq/src/uniq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ impl Uniq {
if bytes_read == 0 {
return Ok(false);
}
if buffer.last().is_some_and(|last| *last == line_terminator) {
buffer.pop();
}
let _ = buffer.pop_if(|last| *last == line_terminator);
Ok(true)
}

Expand Down
Loading