Skip to content

Commit

Permalink
Avoid slow zero-filling initialization
Browse files Browse the repository at this point in the history
warning: slow zero-filling initialization
   --> src/tests/mod.rs:355:5
    |
354 |     let mut result = Vec::new();
    |                      ---------- help: consider replacing this with: `vec![0; original.len()]`
355 |     result.resize(original.len(), 0);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
    = note: `#[warn(clippy::slow_vector_initialization)]` on by default
  • Loading branch information
tamird committed Oct 13, 2023
1 parent e79f098 commit f588d5c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ fn test_streaming_no_std() {
let mut stream = crate::streaming_decoder::StreamingDecoder::new(&mut content).unwrap();

let original = include_bytes!("../../decodecorpus_files/z000088");
let mut result = Vec::new();
result.resize(original.len(), 0);
let mut result = vec![0; original.len()];
Read::read_exact(&mut stream, &mut result).unwrap();

if original.len() != result.len() {
Expand Down Expand Up @@ -391,8 +390,7 @@ fn test_streaming_no_std() {
.unwrap();

let original = include_bytes!("../../decodecorpus_files/z000068");
let mut result = Vec::new();
result.resize(original.len(), 0);
let mut result = vec![0; original.len()];
Read::read_exact(&mut stream, &mut result).unwrap();

std::println!("Results for file:");
Expand Down

0 comments on commit f588d5c

Please sign in to comment.