mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-09 06:01:05 +01:00
Get rid of more unnecessary intermediate collections
This commit is contained in:
parent
06b0c9267f
commit
910ad7fed1
1 changed files with 33 additions and 36 deletions
|
@ -1396,10 +1396,11 @@ async fn upgrade_outlier_to_timeline_pdu(
|
||||||
}
|
}
|
||||||
|
|
||||||
if okay {
|
if okay {
|
||||||
let fork_states: Vec<_> = extremity_sstatehashes
|
let mut fork_states = Vec::with_capacity(extremity_sstatehashes.len());
|
||||||
.into_iter()
|
let mut auth_chain_sets = Vec::with_capacity(extremity_sstatehashes.len());
|
||||||
.map(|(sstatehash, prev_event)| {
|
|
||||||
let mut leaf_state = db
|
for (sstatehash, prev_event) in extremity_sstatehashes {
|
||||||
|
let mut leaf_state: BTreeMap<_, _> = db
|
||||||
.rooms
|
.rooms
|
||||||
.state_full_ids(sstatehash)
|
.state_full_ids(sstatehash)
|
||||||
.map_err(|_| "Failed to ask db for room state.".to_owned())?;
|
.map_err(|_| "Failed to ask db for room state.".to_owned())?;
|
||||||
|
@ -1413,32 +1414,28 @@ async fn upgrade_outlier_to_timeline_pdu(
|
||||||
// Now it's the state after the pdu
|
// Now it's the state after the pdu
|
||||||
}
|
}
|
||||||
|
|
||||||
leaf_state
|
let mut state = StateMap::with_capacity(leaf_state.len());
|
||||||
.into_iter()
|
let mut starting_events = Vec::with_capacity(leaf_state.len());
|
||||||
.map(|(k, id)| (db.rooms.get_statekey_from_short(k).map(|k| (k, id))))
|
|
||||||
.collect::<Result<StateMap<_>>>()
|
for (k, id) in leaf_state {
|
||||||
.map_err(|_| "Failed to get_statekey_from_short.".to_owned())
|
let k = db
|
||||||
})
|
.rooms
|
||||||
.collect::<StdResult<_, _>>()?;
|
.get_statekey_from_short(k)
|
||||||
|
.map_err(|_| "Failed to get_statekey_from_short.".to_owned())?;
|
||||||
|
|
||||||
|
state.insert(k, (*id).clone());
|
||||||
|
starting_events.push(id);
|
||||||
|
}
|
||||||
|
|
||||||
let mut auth_chain_sets = Vec::new();
|
|
||||||
for state in &fork_states {
|
|
||||||
auth_chain_sets.push(
|
auth_chain_sets.push(
|
||||||
get_auth_chain(
|
get_auth_chain(&room_id, starting_events, db)
|
||||||
&room_id,
|
|
||||||
state.iter().map(|(_, id)| id.clone()).collect(),
|
|
||||||
db,
|
|
||||||
)
|
|
||||||
.map_err(|_| "Failed to load auth chain.".to_owned())?
|
.map_err(|_| "Failed to load auth chain.".to_owned())?
|
||||||
.map(|event_id| (*event_id).clone())
|
.map(|event_id| (*event_id).clone())
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
let fork_states = &fork_states
|
fork_states.push(state);
|
||||||
.into_iter()
|
}
|
||||||
.map(|map| map.into_iter().map(|(k, id)| (k, (*id).clone())).collect())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
state_at_incoming_event = match state_res::StateResolution::resolve(
|
state_at_incoming_event = match state_res::StateResolution::resolve(
|
||||||
&room_id,
|
&room_id,
|
||||||
|
|
Loading…
Reference in a new issue