Skip to content

Commit

Permalink
Incorporate clippy reported suggestion
Browse files Browse the repository at this point in the history
Clippy suggests the usage of the vec! macro instead of manually creating
an object and resizing it [0]. Follow the suggestion.

[0] https://rust-lang.github.io/rust-clippy/master/index.html#/slow_vector_initialization

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o authored and danielocfb committed Dec 4, 2023
1 parent 855eb84 commit 63b5c23
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libbpf-rs/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,7 @@ impl MapHandle {
let aligned_val_size = self.percpu_aligned_value_size();
let buf_size = self.percpu_buffer_size()?;

let mut value_buf = Vec::new();
value_buf.resize(buf_size, 0);
let mut value_buf = vec![0; buf_size];

for (i, val) in values.iter().enumerate() {
if val.len() != val_size {
Expand Down

0 comments on commit 63b5c23

Please sign in to comment.