use fast binary_search for some const slices

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-12-15 01:41:50 -05:00
parent 52693db477
commit 6c96acc482
No known key found for this signature in database
6 changed files with 41 additions and 39 deletions

View file

@ -11,7 +11,7 @@ use conduwuit::{
err, error,
pdu::PduBuilder,
utils::{math::usize_from_f64, ReadyExt},
Err, Error, Event, PduEvent, Result,
Err, Error, PduEvent, Result,
};
use futures::StreamExt;
use lru_cache::LruCache;
@ -507,7 +507,7 @@ impl Service {
if redacting_event
.as_ref()
.is_ok_and(|event| event.event_type() == &TimelineEventType::RoomCreate)
.is_ok_and(|pdu| pdu.kind == TimelineEventType::RoomCreate)
{
return Err!(Request(Forbidden("Redacting m.room.create is not safe, forbidding.")));
}

View file

@ -1262,7 +1262,7 @@ impl Service {
#[implement(Service)]
#[tracing::instrument(skip_all, level = "debug")]
async fn check_pdu_for_admin_room(&self, pdu: &PduEvent, sender: &UserId) -> Result<()> {
match pdu.event_type() {
match &pdu.kind {
| TimelineEventType::RoomEncryption => {
return Err!(Request(Forbidden(error!("Encryption not supported in admins room."))));
},

View file

@ -40,7 +40,7 @@ struct CheckForUpdatesResponseEntry {
const CHECK_FOR_UPDATES_URL: &str = "https://pupbrain.dev/check-for-updates/stable";
const CHECK_FOR_UPDATES_INTERVAL: u64 = 7200; // 2 hours
const LAST_CHECK_FOR_UPDATES_COUNT: &[u8] = b"u";
const LAST_CHECK_FOR_UPDATES_COUNT: &[u8; 1] = b"u";
#[async_trait]
impl crate::Service for Service {