use saturating_add and vec with_capacity in even more places

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-06-01 00:49:56 -04:00
parent 4ea7af5780
commit 83220b43a2
6 changed files with 20 additions and 20 deletions

View file

@ -23,7 +23,7 @@ pub(crate) async fn delete(
debug!("Got event ID to delete media from: {event_id}");
let mut mxc_urls = vec![];
let mut mxc_deletion_count = 0;
let mut mxc_deletion_count: usize = 0;
// parsing the PDU for any MXC URLs begins here
if let Some(event_json) = services().rooms.timeline.get_pdu_json(&event_id)? {
@ -123,7 +123,7 @@ pub(crate) async fn delete(
for mxc_url in mxc_urls {
services().media.delete(mxc_url).await?;
mxc_deletion_count += 1;
mxc_deletion_count = mxc_deletion_count.saturating_add(1);
}
return Ok(RoomMessageEventContent::text_plain(format!(

View file

@ -185,7 +185,7 @@ pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) ->
.try_into()
.expect("#admins:server_name is a valid alias name");
let mut room_ban_count = 0;
let mut room_ban_count: usize = 0;
let mut room_ids: Vec<OwnedRoomId> = Vec::new();
for &room in &rooms_s {
@ -297,7 +297,7 @@ pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) ->
for room_id in room_ids {
if services().rooms.metadata.ban_room(&room_id, true).is_ok() {
debug!("Banned {room_id} successfully");
room_ban_count += 1;
room_ban_count = room_ban_count.saturating_add(1);
}
debug!("Making all users leave the room {}", &room_id);