Skip to content

Commit

Permalink
refactor(lib): replace Vec::set_len(0) with clear
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola authored and seanmonstar committed Aug 2, 2018
1 parent 069a32b commit c837fb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/body/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ mod tests {
let chunk = ::Chunk::from(s);
dst.put(chunk);
::test::black_box(&dst);
unsafe { dst.set_len(0); }
dst.clear();
})
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/proto/h1/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ impl<T: AsRef<[u8]>> Cursor<T> {
impl Cursor<Vec<u8>> {
fn reset(&mut self) {
self.pos = 0;
unsafe {
self.bytes.set_len(0);
}
self.bytes.clear();
}
}

Expand Down Expand Up @@ -717,9 +715,7 @@ mod tests {
let chunk = ::Chunk::from(s);
write_buf.buffer(chunk);
::test::black_box(&write_buf);
unsafe {
write_buf.headers.bytes.set_len(0);
}
write_buf.headers.bytes.clear();
})
}
}
5 changes: 1 addition & 4 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,10 +1525,7 @@ mod tests {
assert_eq!(vec.len(), len);
::test::black_box(&vec);

// reset Vec<u8> to 0 (always safe)
unsafe {
vec.set_len(0);
}
vec.clear();
})
}
}
Expand Down

0 comments on commit c837fb9

Please sign in to comment.