We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f9f735 commit 236e220Copy full SHA for 236e220
1 file changed
src/uu/yes/src/yes.rs
@@ -92,14 +92,9 @@ fn args_into_buffer<'a>(
92
/// Assumes buf holds a single output line forged from the command line arguments, copies it
93
/// repeatedly until the buffer holds as many copies as it can under [`BUF_SIZE`].
94
fn prepare_buffer(buf: &mut Vec<u8>) {
95
- if buf.len() * 2 > BUF_SIZE {
96
- return;
97
- }
98
-
99
- assert!(!buf.is_empty());
100
101
let line_len = buf.len();
102
- let target_size = line_len * (BUF_SIZE / line_len);
+ debug_assert!(line_len > 0, "buffer is not empty since we have newline");
+ let target_size = line_len * (BUF_SIZE / line_len); // 0 if line_len is already large enough
103
104
while buf.len() < target_size {
105
let to_copy = std::cmp::min(target_size - buf.len(), buf.len());
0 commit comments