mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-05 03:09:33 +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 0bead9ebe19b97b1e6d6587be07bc2ac57986011)
This commit is contained in:
parent
1446873b28
commit
1ed31abb5d
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user