From c4be0f4235a423dadb226b0d848a788748590d98 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 23 Jun 2021 15:05:38 -0700 Subject: [PATCH] clippy: Address the issue 'needless-collect' error: avoid using `collect()` when not needed --> vmm/src/vm.rs:630:86 | 630 | let node_id_list: Vec = configs.iter().map(|cfg| cfg.guest_numa_id).collect(); | ^^^^^^^ ... 664 | if !node_id_list.contains(&dest) { | ---------------------------- the iterator could be used here instead | = note: `-D clippy::needless-collect` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect Signed-off-by: Bo Chen --- vmm/src/vm.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index d9a6abff0..f1d5ad050 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -624,8 +624,6 @@ impl Vm { let mut numa_nodes = BTreeMap::new(); if let Some(configs) = &configs { - let node_id_list: Vec = configs.iter().map(|cfg| cfg.guest_numa_id).collect(); - for config in configs.iter() { if numa_nodes.contains_key(&config.guest_numa_id) { error!("Can't define twice the same NUMA node"); @@ -658,7 +656,7 @@ impl Vm { let dest = distance.destination; let dist = distance.distance; - if !node_id_list.contains(&dest) { + if !configs.iter().any(|cfg| cfg.guest_numa_id == dest) { error!("Unknown destination NUMA node {}", dest); return Err(Error::InvalidNumaConfig); }