miniscule spaces code optimisations
still terrible though Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
bd56d83045
commit
fa7c1200b5
1 changed files with 13 additions and 12 deletions
|
@ -62,11 +62,11 @@ impl FromStr for PaginationToken {
|
||||||
let mut values = value.split('_');
|
let mut values = value.split('_');
|
||||||
|
|
||||||
let mut pag_tok = || {
|
let mut pag_tok = || {
|
||||||
let mut rooms = vec![];
|
let rooms = values
|
||||||
|
.next()?
|
||||||
for room in values.next()?.split(',') {
|
.split(',')
|
||||||
rooms.push(u64::from_str(room).ok()?);
|
.filter_map(|room_s| u64::from_str(room_s).ok())
|
||||||
}
|
.collect();
|
||||||
|
|
||||||
Some(Self {
|
Some(Self {
|
||||||
short_room_ids: rooms,
|
short_room_ids: rooms,
|
||||||
|
@ -469,7 +469,7 @@ impl Service {
|
||||||
},
|
},
|
||||||
)]];
|
)]];
|
||||||
|
|
||||||
let mut results = Vec::new();
|
let mut results = Vec::with_capacity(limit);
|
||||||
|
|
||||||
while let Some((current_room, via)) = { next_room_to_traverse(&mut stack, &mut parents) } {
|
while let Some((current_room, via)) = { next_room_to_traverse(&mut stack, &mut parents) } {
|
||||||
if results.len() >= limit {
|
if results.len() >= limit {
|
||||||
|
@ -548,11 +548,12 @@ impl Service {
|
||||||
parents.pop_front();
|
parents.pop_front();
|
||||||
parents.push_back(room);
|
parents.push_back(room);
|
||||||
|
|
||||||
let mut short_room_ids = vec![];
|
let short_room_ids: Vec<_> = parents
|
||||||
|
.iter()
|
||||||
for room in parents {
|
.stream()
|
||||||
short_room_ids.push(self.services.short.get_or_create_shortroomid(&room).await);
|
.filter_map(|room_id| async move { self.services.short.get_shortroomid(room_id).await.ok() })
|
||||||
}
|
.collect()
|
||||||
|
.await;
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
PaginationToken {
|
PaginationToken {
|
||||||
|
@ -585,7 +586,7 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.map_err(|e| err!(Database("State in space not found: {e}")))?;
|
.map_err(|e| err!(Database("State in space not found: {e}")))?;
|
||||||
|
|
||||||
let mut children_pdus = Vec::new();
|
let mut children_pdus = Vec::with_capacity(state.len());
|
||||||
for (key, id) in state {
|
for (key, id) in state {
|
||||||
let (event_type, state_key) = self.services.short.get_statekey_from_short(key).await?;
|
let (event_type, state_key) = self.services.short.get_statekey_from_short(key).await?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue