X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Findexed_map.rs;h=d4c20f722154fe499c68a296c45f25d8dd55aff4;hb=07059ec2c311e2904263e49f5ad976054ef719c1;hp=39565f048c07a25f30a6749b5057a55a15278664;hpb=103180df8f3ab77d1d5282bc8546b3072aaa55ec;p=rust-lightning diff --git a/lightning/src/util/indexed_map.rs b/lightning/src/util/indexed_map.rs index 39565f04..d4c20f72 100644 --- a/lightning/src/util/indexed_map.rs +++ b/lightning/src/util/indexed_map.rs @@ -1,6 +1,6 @@ //! This module has a map which can be iterated in a deterministic order. See the [`IndexedMap`]. -use crate::prelude::{HashMap, hash_map}; +use crate::prelude::*; use alloc::vec::Vec; use alloc::slice::Iter; use core::hash::Hash; @@ -34,7 +34,7 @@ impl IndexedMap { /// Constructs a new, empty map pub fn new() -> Self { Self { - map: HashMap::new(), + map: new_hash_map(), keys: Vec::new(), } } @@ -42,7 +42,7 @@ impl IndexedMap { /// Constructs a new, empty map with the given capacity pre-allocated pub fn with_capacity(capacity: usize) -> Self { Self { - map: HashMap::with_capacity(capacity), + map: hash_map_with_capacity(capacity), keys: Vec::with_capacity(capacity), } } @@ -176,10 +176,7 @@ impl<'a, K: Hash + Ord, V: 'a> Iterator for Range<'a, K, V> { /// /// This is not exported to bindings users as bindings provide alternate accessors rather than exposing maps directly. pub struct VacantEntry<'a, K: Hash + Ord, V> { - #[cfg(feature = "hashbrown")] - underlying_entry: hash_map::VacantEntry<'a, K, V, hash_map::DefaultHashBuilder>, - #[cfg(not(feature = "hashbrown"))] - underlying_entry: hash_map::VacantEntry<'a, K, V>, + underlying_entry: VacantHashMapEntry<'a, K, V>, key: K, keys: &'a mut Vec, } @@ -188,10 +185,7 @@ pub struct VacantEntry<'a, K: Hash + Ord, V> { /// /// This is not exported to bindings users as bindings provide alternate accessors rather than exposing maps directly. pub struct OccupiedEntry<'a, K: Hash + Ord, V> { - #[cfg(feature = "hashbrown")] - underlying_entry: hash_map::OccupiedEntry<'a, K, V, hash_map::DefaultHashBuilder>, - #[cfg(not(feature = "hashbrown"))] - underlying_entry: hash_map::OccupiedEntry<'a, K, V>, + underlying_entry: OccupiedHashMapEntry<'a, K, V>, keys: &'a mut Vec, }