mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +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>
This commit is contained in:
parent
05a86d892e
commit
0bead9ebe1
@ -1776,8 +1776,7 @@ impl Cpu {
|
||||
_reserved: 0,
|
||||
};
|
||||
|
||||
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)];
|
||||
// SAFETY: mat_data is large enough to hold lapic
|
||||
unsafe { *(mat_data.as_mut_ptr() as *mut LocalX2Apic) = lapic };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user