init a few state hashmaps using with_capacity
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
f0533e07ef
commit
1ac72ab914
1 changed files with 5 additions and 5 deletions
|
@ -375,7 +375,7 @@ impl Service {
|
||||||
// auth events
|
// auth events
|
||||||
debug!("Checking based on auth events");
|
debug!("Checking based on auth events");
|
||||||
// Build map of auth events
|
// Build map of auth events
|
||||||
let mut auth_events = HashMap::new();
|
let mut auth_events = HashMap::with_capacity(incoming_pdu.auth_events.len());
|
||||||
for id in &incoming_pdu.auth_events {
|
for id in &incoming_pdu.auth_events {
|
||||||
let Some(auth_event) = services().rooms.timeline.get_pdu(id)? else {
|
let Some(auth_event) = services().rooms.timeline.get_pdu(id)? else {
|
||||||
warn!("Could not find auth event {}", id);
|
warn!("Could not find auth event {}", id);
|
||||||
|
@ -814,7 +814,7 @@ impl Service {
|
||||||
&self, incoming_pdu: &Arc<PduEvent>, room_id: &RoomId, room_version_id: &RoomVersionId,
|
&self, incoming_pdu: &Arc<PduEvent>, room_id: &RoomId, room_version_id: &RoomVersionId,
|
||||||
) -> Result<Option<HashMap<u64, Arc<EventId>>>> {
|
) -> Result<Option<HashMap<u64, Arc<EventId>>>> {
|
||||||
debug!("Calculating state at event using state res");
|
debug!("Calculating state at event using state res");
|
||||||
let mut extremity_sstatehashes = HashMap::new();
|
let mut extremity_sstatehashes = HashMap::with_capacity(incoming_pdu.prev_events.len());
|
||||||
|
|
||||||
let mut okay = true;
|
let mut okay = true;
|
||||||
for prev_eventid in &incoming_pdu.prev_events {
|
for prev_eventid in &incoming_pdu.prev_events {
|
||||||
|
@ -949,7 +949,7 @@ impl Service {
|
||||||
.fetch_and_handle_outliers(origin, &collect, create_event, room_id, room_version_id, pub_key_map)
|
.fetch_and_handle_outliers(origin, &collect, create_event, room_id, room_version_id, pub_key_map)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let mut state: HashMap<_, Arc<EventId>> = HashMap::new();
|
let mut state: HashMap<_, Arc<EventId>> = HashMap::with_capacity(state_vec.len());
|
||||||
for (pdu, _) in state_vec {
|
for (pdu, _) in state_vec {
|
||||||
let state_key = pdu
|
let state_key = pdu
|
||||||
.state_key
|
.state_key
|
||||||
|
@ -1196,7 +1196,7 @@ impl Service {
|
||||||
Vec<Arc<EventId>>,
|
Vec<Arc<EventId>>,
|
||||||
HashMap<Arc<EventId>, (Arc<PduEvent>, BTreeMap<String, CanonicalJsonValue>)>,
|
HashMap<Arc<EventId>, (Arc<PduEvent>, BTreeMap<String, CanonicalJsonValue>)>,
|
||||||
)> {
|
)> {
|
||||||
let mut graph: HashMap<Arc<EventId>, _> = HashMap::new();
|
let mut graph: HashMap<Arc<EventId>, _> = HashMap::with_capacity(initial_set.len());
|
||||||
let mut eventid_info = HashMap::new();
|
let mut eventid_info = HashMap::new();
|
||||||
let mut todo_outlier_stack: Vec<Arc<EventId>> = initial_set;
|
let mut todo_outlier_stack: Vec<Arc<EventId>> = initial_set;
|
||||||
|
|
||||||
|
@ -1242,7 +1242,7 @@ impl Service {
|
||||||
.flatten()
|
.flatten()
|
||||||
}) {
|
}) {
|
||||||
if pdu.origin_server_ts > first_pdu_in_room.origin_server_ts {
|
if pdu.origin_server_ts > first_pdu_in_room.origin_server_ts {
|
||||||
amount += 1;
|
amount = amount.saturating_add(1);
|
||||||
for prev_prev in &pdu.prev_events {
|
for prev_prev in &pdu.prev_events {
|
||||||
if !graph.contains_key(prev_prev) {
|
if !graph.contains_key(prev_prev) {
|
||||||
todo_outlier_stack.push(prev_prev.clone());
|
todo_outlier_stack.push(prev_prev.clone());
|
||||||
|
|
Loading…
Add table
Reference in a new issue