Skip to content

Commit 5129b8b

Browse files
committed
refactor(s2n-quic-dc): put map impl behind trait
1 parent 01cbb44 commit 5129b8b

File tree

11 files changed

+1260
-1044
lines changed

11 files changed

+1260
-1044
lines changed

dc/s2n-quic-dc/src/fixed_map.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use core::{
1212
hash::Hash,
1313
sync::atomic::{AtomicU8, Ordering},
1414
};
15-
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard};
15+
use parking_lot::{RwLock, RwLockReadGuard, RwLockUpgradableReadGuard};
1616
use std::{collections::hash_map::RandomState, hash::BuildHasher};
1717

18+
pub use parking_lot::MappedRwLockReadGuard as ReadGuard;
19+
1820
pub struct Map<K, V, S = RandomState> {
1921
slots: Box<[Slot<K, V>]>,
2022
hash_builder: S,
@@ -94,7 +96,7 @@ where
9496
self.get_by_key(key).is_some()
9597
}
9698

97-
pub fn get_by_key(&self, key: &K) -> Option<MappedRwLockReadGuard<'_, V>> {
99+
pub fn get_by_key(&self, key: &K) -> Option<ReadGuard<'_, V>> {
98100
self.slot_by_hash(key).get_by_key(key)
99101
}
100102
}
@@ -148,7 +150,7 @@ where
148150
None
149151
}
150152

151-
fn get_by_key(&self, needle: &K) -> Option<MappedRwLockReadGuard<'_, V>> {
153+
fn get_by_key(&self, needle: &K) -> Option<ReadGuard<'_, V>> {
152154
// Scan each value and check if our requested needle is present.
153155
let values = self.values.read();
154156
for (value_idx, value) in values.iter().enumerate() {

0 commit comments

Comments
 (0)