optimize with SmallString; consolidate related re-exports

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-02-08 00:16:37 +00:00 committed by strawberry
parent ecc9099127
commit b872f8e593
39 changed files with 113 additions and 96 deletions

View file

@ -6,10 +6,8 @@ use std::{
use conduwuit::{debug, debug_info, err, implement, trace, warn, Err, Error, PduEvent, Result};
use futures::{future::ready, TryFutureExt};
use ruma::{
api::client::error::ErrorKind,
events::StateEventType,
state_res::{self, EventTypeExt},
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, ServerName,
api::client::error::ErrorKind, events::StateEventType, state_res, CanonicalJsonObject,
CanonicalJsonValue, EventId, RoomId, ServerName,
};
use super::{check_room_id, get_room_version_id, to_room_version};
@ -123,7 +121,7 @@ pub(super) async fn handle_outlier_pdu<'a>(
// The original create event must be in the auth events
if !matches!(
auth_events
.get(&(StateEventType::RoomCreate, String::new()))
.get(&(StateEventType::RoomCreate, String::new().into()))
.map(AsRef::as_ref),
Some(_) | None
) {
@ -134,7 +132,7 @@ pub(super) async fn handle_outlier_pdu<'a>(
}
let state_fetch = |ty: &'static StateEventType, sk: &str| {
let key = ty.with_state_key(sk);
let key = (ty.to_owned(), sk.into());
ready(auth_events.get(&key))
};

View file

@ -64,6 +64,7 @@ pub async fn resolve_state(
.multi_get_statekey_from_short(shortstatekeys)
.zip(event_ids)
.ready_filter_map(|(ty_sk, id)| Some((ty_sk.ok()?, id)))
.map(|((ty, sk), id)| ((ty, sk.as_str().to_owned()), id))
.collect()
})
.map(Ok::<_, Error>)

View file

@ -172,6 +172,7 @@ async fn state_at_incoming_fork(
.short
.get_statekey_from_short(*k)
.map_ok(|(ty, sk)| ((ty, sk), id.clone()))
.map_ok(|((ty, sk), id)| ((ty, sk.as_str().to_owned()), id))
})
.ready_filter_map(Result::ok)
.collect()