mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: cpu: Fix slow vector initialization
warning: slow zero-filling initialization
--> vmm/src/cpu.rs:1780:9
|
1779 | let mut mat_data: Vec<u8> = Vec::new();
| ---------- help: consider replacing this with: `vec![0; std::mem::size_of_val(&lapic)]`
1780 | mat_data.resize(std::mem::size_of_val(&lapic), 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
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
(cherry picked from commit 0bead9ebe1)
This commit is contained in:
@@ -1733,8 +1733,7 @@ impl Cpu {
|
||||
flags: 1 << MADT_CPU_ENABLE_FLAG,
|
||||
};
|
||||
|
||||
let mut mat_data: Vec<u8> = Vec::new();
|
||||
mat_data.resize(std::mem::size_of_val(&lapic), 0);
|
||||
let mut mat_data: Vec<u8> = vec![0; std::mem::size_of_val(&lapic)];
|
||||
unsafe { *(mat_data.as_mut_ptr() as *mut LocalApic) = lapic };
|
||||
|
||||
mat_data
|
||||
|
||||
Reference in New Issue
Block a user