inline analysis and symbol reduction; emits smaller than 64 bytes marked inline
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1e8b8cce0f
commit
eeda96d94a
35 changed files with 117 additions and 73 deletions
|
@ -1381,6 +1381,7 @@ impl Service {
|
|||
Ok(create_event_content.room_version)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_room_version(room_version_id: &RoomVersionId) -> RoomVersion {
|
||||
RoomVersion::new(room_version_id).expect("room version is supported")
|
||||
}
|
||||
|
|
|
@ -201,6 +201,7 @@ impl super::Service {
|
|||
|
||||
let result = services()
|
||||
.globals
|
||||
.db
|
||||
.add_signing_key(&k.server_name, k.clone())?
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k.to_string(), v.key))
|
||||
|
@ -249,6 +250,7 @@ impl super::Service {
|
|||
if let Ok(key) = get_keys_response.server_key.deserialize() {
|
||||
let result: BTreeMap<_, _> = services()
|
||||
.globals
|
||||
.db
|
||||
.add_signing_key(&origin, key)?
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k.to_string(), v.key))
|
||||
|
@ -392,7 +394,7 @@ impl super::Service {
|
|||
}) {
|
||||
debug!("Got signing keys: {:?}", server_keys);
|
||||
for k in server_keys {
|
||||
services().globals.add_signing_key(origin, k.clone())?;
|
||||
services().globals.db.add_signing_key(origin, k.clone())?;
|
||||
result.extend(
|
||||
k.verify_keys
|
||||
.into_iter()
|
||||
|
@ -421,6 +423,7 @@ impl super::Service {
|
|||
{
|
||||
services()
|
||||
.globals
|
||||
.db
|
||||
.add_signing_key(origin, server_key.clone())?;
|
||||
|
||||
result.extend(
|
||||
|
@ -453,6 +456,7 @@ impl super::Service {
|
|||
{
|
||||
services()
|
||||
.globals
|
||||
.db
|
||||
.add_signing_key(origin, server_key.clone())?;
|
||||
|
||||
result.extend(
|
||||
|
@ -499,7 +503,7 @@ impl super::Service {
|
|||
}) {
|
||||
debug!("Got signing keys: {:?}", server_keys);
|
||||
for k in server_keys {
|
||||
services().globals.add_signing_key(origin, k.clone())?;
|
||||
services().globals.db.add_signing_key(origin, k.clone())?;
|
||||
result.extend(
|
||||
k.verify_keys
|
||||
.into_iter()
|
||||
|
|
|
@ -48,10 +48,12 @@ impl Data {
|
|||
}))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn is_disabled(&self, room_id: &RoomId) -> Result<bool> {
|
||||
Ok(self.disabledroomids.get(room_id.as_bytes())?.is_some())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()> {
|
||||
if disabled {
|
||||
self.disabledroomids.insert(room_id.as_bytes(), &[])?;
|
||||
|
@ -62,10 +64,12 @@ impl Data {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn is_banned(&self, room_id: &RoomId) -> Result<bool> {
|
||||
Ok(self.bannedroomids.get(room_id.as_bytes())?.is_some())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()> {
|
||||
if banned {
|
||||
self.bannedroomids.insert(room_id.as_bytes(), &[])?;
|
||||
|
|
|
@ -22,22 +22,27 @@ impl crate::Service for Service {
|
|||
|
||||
impl Service {
|
||||
/// Checks if a room exists.
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[inline]
|
||||
pub fn exists(&self, room_id: &RoomId) -> Result<bool> { self.db.exists(room_id) }
|
||||
|
||||
#[must_use]
|
||||
pub fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> { self.db.iter_ids() }
|
||||
|
||||
#[inline]
|
||||
pub fn is_disabled(&self, room_id: &RoomId) -> Result<bool> { self.db.is_disabled(room_id) }
|
||||
|
||||
#[inline]
|
||||
pub fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()> {
|
||||
self.db.disable_room(room_id, disabled)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_banned(&self, room_id: &RoomId) -> Result<bool> { self.db.is_banned(room_id) }
|
||||
|
||||
#[inline]
|
||||
pub fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()> { self.db.ban_room(room_id, banned) }
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn list_banned_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
|
||||
self.db.list_banned_rooms()
|
||||
|
|
|
@ -30,6 +30,7 @@ impl Data {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn set_room_state(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
|
|
@ -200,6 +200,7 @@ impl Service {
|
|||
if let Some(state_key) = &new_pdu.state_key {
|
||||
let states_parents = previous_shortstatehash.map_or_else(
|
||||
|| Ok(Vec::new()),
|
||||
#[inline]
|
||||
|p| {
|
||||
services()
|
||||
.rooms
|
||||
|
@ -344,6 +345,7 @@ impl Service {
|
|||
Ok(create_event_content.room_version)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_room_shortstatehash(&self, room_id: &RoomId) -> Result<Option<u64>> {
|
||||
self.db.get_room_shortstatehash(room_id)
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ impl Service {
|
|||
|
||||
/// Returns a single PDU from `room_id` with key (`event_type`,
|
||||
/// `state_key`).
|
||||
#[inline]
|
||||
pub fn state_get(
|
||||
&self, shortstatehash: u64, event_type: &StateEventType, state_key: &str,
|
||||
) -> Result<Option<Arc<PduEvent>>> {
|
||||
|
@ -113,6 +114,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// The user was a joined member at this state (potentially in the past)
|
||||
#[inline]
|
||||
fn user_was_joined(&self, shortstatehash: u64, user_id: &UserId) -> bool {
|
||||
self.user_membership(shortstatehash, user_id)
|
||||
.is_ok_and(|s| s == MembershipState::Join)
|
||||
|
@ -122,6 +124,7 @@ impl Service {
|
|||
|
||||
/// The user was an invited or joined room member at this state (potentially
|
||||
/// in the past)
|
||||
#[inline]
|
||||
fn user_was_invited(&self, shortstatehash: u64, user_id: &UserId) -> bool {
|
||||
self.user_membership(shortstatehash, user_id)
|
||||
.is_ok_and(|s| s == MembershipState::Join || s == MembershipState::Invite)
|
||||
|
|
|
@ -135,6 +135,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns shortstatekey, event id
|
||||
#[inline]
|
||||
pub fn parse_compressed_state_event(&self, compressed_event: &CompressedStateEvent) -> Result<(u64, Arc<EventId>)> {
|
||||
Ok((
|
||||
utils::u64_from_bytes(&compressed_event[0..size_of::<u64>()]).expect("bytes have right length"),
|
||||
|
|
|
@ -97,6 +97,7 @@ impl Data {
|
|||
}
|
||||
|
||||
/// Returns the pdu's id.
|
||||
#[inline]
|
||||
pub(super) fn get_pdu_id(&self, event_id: &EventId) -> Result<Option<database::Handle<'_>>> {
|
||||
self.eventid_pduid.get(event_id.as_bytes())
|
||||
}
|
||||
|
|
|
@ -175,11 +175,13 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns the json of a pdu.
|
||||
#[inline]
|
||||
pub fn get_non_outlier_pdu_json(&self, event_id: &EventId) -> Result<Option<CanonicalJsonObject>> {
|
||||
self.db.get_non_outlier_pdu_json(event_id)
|
||||
}
|
||||
|
||||
/// Returns the pdu's id.
|
||||
#[inline]
|
||||
pub fn get_pdu_id(&self, event_id: &EventId) -> Result<Option<database::Handle<'_>>> {
|
||||
self.db.get_pdu_id(event_id)
|
||||
}
|
||||
|
@ -190,6 +192,7 @@ impl Service {
|
|||
///
|
||||
/// TODO: use this?
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
pub fn get_non_outlier_pdu(&self, event_id: &EventId) -> Result<Option<PduEvent>> {
|
||||
self.db.get_non_outlier_pdu(event_id)
|
||||
}
|
||||
|
@ -1017,6 +1020,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all PDUs in a room.
|
||||
#[inline]
|
||||
pub fn all_pdus<'a>(
|
||||
&'a self, user_id: &UserId, room_id: &RoomId,
|
||||
) -> Result<impl Iterator<Item = Result<(PduCount, PduEvent)>> + 'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue