From 9a2de993b847d3fc26571437e22ea43a014ac809 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 15 Oct 2020 13:01:22 -0400 Subject: [PATCH] One less Vec indirection --- src/datastore.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/datastore.rs b/src/datastore.rs index 0b608f9..6f43458 100644 --- a/src/datastore.rs +++ b/src/datastore.rs @@ -174,12 +174,12 @@ impl SockAddr { struct Nodes { good_node_services: [HashSet; 64], nodes_to_state: HashMap, - state_next_scan: Vec>, + state_next_scan: [Vec; AddressState::get_count() as usize], } struct NodesMutRef<'a> { good_node_services: &'a mut [HashSet; 64], nodes_to_state: &'a mut HashMap, - state_next_scan: &'a mut Vec>, + state_next_scan: &'a mut [Vec; AddressState::get_count() as usize], } impl Nodes { @@ -262,10 +262,7 @@ impl Store { macro_rules! nodes_uninitd { () => { { - let mut state_vecs = Vec::with_capacity(AddressState::get_count() as usize); - for _ in 0..AddressState::get_count() { - state_vecs.push(Vec::new()); - } + let state_vecs = [Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new()]; let good_node_services = [HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new(), HashSet::new()]; Nodes { good_node_services, -- 2.30.2