Skip to content

Commit

Permalink
Refactor: Tight up unix::Client::new impl
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jun 29, 2022
1 parent 0345ff6 commit ff1c741
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ impl Client {
// 128 cores.
const BUFFER: [u8; 128] = [b'|'; 128];

while limit >= BUFFER.len() {
(&client.write).write_all(&BUFFER)?;
limit -= BUFFER.len();
}
while limit > 0 {
let n = limit.min(BUFFER.len());

if limit > 0 {
(&client.write).write_all(&BUFFER[..limit])?;
(&client.write).write_all(&BUFFER[..n])?;
limit -= n;
}

Ok(client)
Expand Down

0 comments on commit ff1c741

Please sign in to comment.