fix unnecessary re-serializations

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-09 03:37:13 +00:00 committed by strawberry
parent 8eec78e9e0
commit 814b9e28b6
7 changed files with 9 additions and 11 deletions

View file

@ -18,8 +18,7 @@ where
K: Deserialize<'a> + Send,
V: Deserialize<'a> + Send,
{
let key = ser::serialize_to_vec(from).expect("failed to serialize query key");
self.rev_stream_raw_from(&key)
self.rev_stream_raw_from(from)
.map(keyval::result_deserialize::<K, V>)
}

View file

@ -18,8 +18,7 @@ where
K: Deserialize<'a> + Send,
V: Deserialize<'a> + Send,
{
let key = ser::serialize_to_vec(from).expect("failed to serialize query key");
self.stream_raw_from(&key)
self.stream_raw_from(from)
.map(keyval::result_deserialize::<K, V>)
}

View file

@ -85,8 +85,8 @@ pub fn list_banned_rooms(&self) -> impl Stream<Item = &RoomId> + Send + '_ { sel
#[implement(Service)]
#[inline]
pub async fn is_disabled(&self, room_id: &RoomId) -> bool { self.db.disabledroomids.qry(room_id).await.is_ok() }
pub async fn is_disabled(&self, room_id: &RoomId) -> bool { self.db.disabledroomids.get(room_id).await.is_ok() }
#[implement(Service)]
#[inline]
pub async fn is_banned(&self, room_id: &RoomId) -> bool { self.db.bannedroomids.qry(room_id).await.is_ok() }
pub async fn is_banned(&self, room_id: &RoomId) -> bool { self.db.bannedroomids.get(room_id).await.is_ok() }

View file

@ -94,6 +94,6 @@ impl Data {
}
pub(super) async fn is_event_soft_failed(&self, event_id: &EventId) -> bool {
self.softfailedeventids.qry(event_id).await.is_ok()
self.softfailedeventids.get(event_id).await.is_ok()
}
}

View file

@ -197,7 +197,7 @@ pub async fn get_or_create_shortstatehash(&self, state_hash: &[u8]) -> (u64, boo
#[implement(Service)]
pub async fn get_shortroomid(&self, room_id: &RoomId) -> Result<u64> {
self.db.roomid_shortroomid.qry(room_id).await.deserialized()
self.db.roomid_shortroomid.get(room_id).await.deserialized()
}
#[implement(Service)]

View file

@ -342,7 +342,7 @@ impl Service {
/// Returns the number of users which are currently in a room
#[tracing::instrument(skip(self), level = "debug")]
pub async fn room_joined_count(&self, room_id: &RoomId) -> Result<u64> {
self.db.roomid_joinedcount.qry(room_id).await.deserialized()
self.db.roomid_joinedcount.get(room_id).await.deserialized()
}
#[tracing::instrument(skip(self), level = "debug")]
@ -366,7 +366,7 @@ impl Service {
pub async fn room_invited_count(&self, room_id: &RoomId) -> Result<u64> {
self.db
.roomid_invitedcount
.qry(room_id)
.get(room_id)
.await
.deserialized()
}

View file

@ -128,7 +128,7 @@ impl Service {
pub async fn last_check_for_updates_id(&self) -> u64 {
self.db
.qry(LAST_CHECK_FOR_UPDATES_COUNT)
.get(LAST_CHECK_FOR_UPDATES_COUNT)
.await
.deserialized()
.unwrap_or(0_u64)