Simplify struct initializations by using Default::default
parent
cfa69e74f4
commit
a5ff4fbef7
|
@ -571,13 +571,13 @@ impl Client {
|
|||
http_client,
|
||||
base_client,
|
||||
#[cfg(feature = "encryption")]
|
||||
group_session_locks: Arc::new(DashMap::new()),
|
||||
group_session_locks: Default::default(),
|
||||
#[cfg(feature = "encryption")]
|
||||
key_claim_lock: Arc::new(Mutex::new(())),
|
||||
members_request_locks: Arc::new(DashMap::new()),
|
||||
typing_notice_times: Arc::new(DashMap::new()),
|
||||
event_handlers: Arc::new(RwLock::new(BTreeMap::new())),
|
||||
notification_handlers: Arc::new(RwLock::new(Vec::new())),
|
||||
key_claim_lock: Default::default(),
|
||||
members_request_locks: Default::default(),
|
||||
typing_notice_times: Default::default(),
|
||||
event_handlers: Default::default(),
|
||||
notification_handlers: Default::default(),
|
||||
appservice_mode: config.appservice_mode,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -72,23 +72,23 @@ impl MemoryStore {
|
|||
#[allow(dead_code)]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
sync_token: Arc::new(RwLock::new(None)),
|
||||
filters: DashMap::new().into(),
|
||||
account_data: DashMap::new().into(),
|
||||
members: DashMap::new().into(),
|
||||
profiles: DashMap::new().into(),
|
||||
display_names: DashMap::new().into(),
|
||||
joined_user_ids: DashMap::new().into(),
|
||||
invited_user_ids: DashMap::new().into(),
|
||||
room_info: DashMap::new().into(),
|
||||
room_state: DashMap::new().into(),
|
||||
room_account_data: DashMap::new().into(),
|
||||
stripped_room_info: DashMap::new().into(),
|
||||
stripped_room_state: DashMap::new().into(),
|
||||
stripped_members: DashMap::new().into(),
|
||||
presence: DashMap::new().into(),
|
||||
room_user_receipts: DashMap::new().into(),
|
||||
room_event_receipts: DashMap::new().into(),
|
||||
sync_token: Default::default(),
|
||||
filters: Default::default(),
|
||||
account_data: Default::default(),
|
||||
members: Default::default(),
|
||||
profiles: Default::default(),
|
||||
display_names: Default::default(),
|
||||
joined_user_ids: Default::default(),
|
||||
invited_user_ids: Default::default(),
|
||||
room_info: Default::default(),
|
||||
room_state: Default::default(),
|
||||
room_account_data: Default::default(),
|
||||
stripped_room_info: Default::default(),
|
||||
stripped_room_state: Default::default(),
|
||||
stripped_members: Default::default(),
|
||||
presence: Default::default(),
|
||||
room_user_receipts: Default::default(),
|
||||
room_event_receipts: Default::default(),
|
||||
media: Arc::new(Mutex::new(LruCache::new(100))),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,15 +310,12 @@ pub struct Store {
|
|||
|
||||
impl Store {
|
||||
fn new(inner: Box<dyn StateStore>) -> Self {
|
||||
let session = Arc::new(RwLock::new(None));
|
||||
let sync_token = Arc::new(RwLock::new(None));
|
||||
|
||||
Self {
|
||||
inner: inner.into(),
|
||||
session,
|
||||
sync_token,
|
||||
rooms: DashMap::new().into(),
|
||||
stripped_rooms: DashMap::new().into(),
|
||||
session: Default::default(),
|
||||
sync_token: Default::default(),
|
||||
rooms: Default::default(),
|
||||
stripped_rooms: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ impl GossipMachine {
|
|||
device_id,
|
||||
store,
|
||||
outbound_group_sessions,
|
||||
outgoing_requests: DashMap::new().into(),
|
||||
incoming_key_requests: DashMap::new().into(),
|
||||
outgoing_requests: Default::default(),
|
||||
incoming_key_requests: Default::default(),
|
||||
wait_queue: WaitQueue::new(),
|
||||
users_for_key_claim,
|
||||
}
|
||||
|
|
|
@ -49,11 +49,7 @@ pub(crate) struct GroupSessionCache {
|
|||
|
||||
impl GroupSessionCache {
|
||||
pub(crate) fn new(store: Store) -> Self {
|
||||
Self {
|
||||
store,
|
||||
sessions: DashMap::new().into(),
|
||||
sessions_being_shared: Arc::new(DashMap::new()),
|
||||
}
|
||||
Self { store, sessions: Default::default(), sessions_being_shared: Default::default() }
|
||||
}
|
||||
|
||||
pub(crate) fn insert(&self, session: OutboundGroupSession) {
|
||||
|
|
|
@ -64,8 +64,8 @@ impl SessionManager {
|
|||
store,
|
||||
key_request_machine,
|
||||
users_for_key_claim,
|
||||
wedged_devices: Arc::new(DashMap::new()),
|
||||
outgoing_to_device_requests: Arc::new(DashMap::new()),
|
||||
wedged_devices: Default::default(),
|
||||
outgoing_to_device_requests: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub struct SessionStore {
|
|||
impl SessionStore {
|
||||
/// Create a new empty Session store.
|
||||
pub fn new() -> Self {
|
||||
SessionStore { entries: Arc::new(DashMap::new()) }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Add a session to the store.
|
||||
|
@ -82,7 +82,7 @@ pub struct GroupSessionStore {
|
|||
impl GroupSessionStore {
|
||||
/// Create a new empty store.
|
||||
pub fn new() -> Self {
|
||||
GroupSessionStore { entries: Arc::new(DashMap::new()) }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Add an inbound group session to the store.
|
||||
|
@ -141,7 +141,7 @@ pub struct DeviceStore {
|
|||
impl DeviceStore {
|
||||
/// Create a new empty device store.
|
||||
pub fn new() -> Self {
|
||||
DeviceStore { entries: Arc::new(DashMap::new()) }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Add a device to the store.
|
||||
|
|
|
@ -59,13 +59,13 @@ impl Default for MemoryStore {
|
|||
MemoryStore {
|
||||
sessions: SessionStore::new(),
|
||||
inbound_group_sessions: GroupSessionStore::new(),
|
||||
tracked_users: Arc::new(DashSet::new()),
|
||||
users_for_key_query: Arc::new(DashSet::new()),
|
||||
olm_hashes: Arc::new(DashMap::new()),
|
||||
tracked_users: Default::default(),
|
||||
users_for_key_query: Default::default(),
|
||||
olm_hashes: Default::default(),
|
||||
devices: DeviceStore::new(),
|
||||
identities: Arc::new(DashMap::new()),
|
||||
outgoing_key_requests: Arc::new(DashMap::new()),
|
||||
key_requests_by_info: Arc::new(DashMap::new()),
|
||||
identities: Default::default(),
|
||||
outgoing_key_requests: Default::default(),
|
||||
key_requests_by_info: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct VerificationCache {
|
|||
|
||||
impl VerificationCache {
|
||||
pub fn new() -> Self {
|
||||
Self { verification: DashMap::new().into(), outgoing_requests: DashMap::new().into() }
|
||||
Self { verification: Default::default(), outgoing_requests: Default::default() }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -62,7 +62,7 @@ impl VerificationMachine {
|
|||
private_identity: identity,
|
||||
store: VerificationStore { account, inner: store },
|
||||
verifications: VerificationCache::new(),
|
||||
requests: DashMap::new().into(),
|
||||
requests: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue