From: Matt Corallo Date: Thu, 15 Oct 2020 17:01:22 +0000 (-0400) Subject: One less Vec indirection X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=dnsseed-rust;a=commitdiff_plain;h=9a2de993b847d3fc26571437e22ea43a014ac809 One less Vec indirection --- 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,