correct arithmetic adjustments
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
16a98b0683
commit
321e197d8c
12 changed files with 24 additions and 53 deletions
|
@ -340,13 +340,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
|||
e.insert((Instant::now(), 1));
|
||||
},
|
||||
hash_map::Entry::Occupied(mut e) => {
|
||||
*e.get_mut() = (
|
||||
Instant::now(),
|
||||
e.get()
|
||||
.1
|
||||
.checked_add(1)
|
||||
.expect("bad_query_ratelimiter attempt/try count should not ever get this high"),
|
||||
);
|
||||
*e.get_mut() = (Instant::now(), e.get().1.saturating_add(1));
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1395,13 +1395,7 @@ async fn validate_and_add_event_id(
|
|||
e.insert((Instant::now(), 1));
|
||||
},
|
||||
Entry::Occupied(mut e) => {
|
||||
*e.get_mut() = (
|
||||
Instant::now(),
|
||||
e.get()
|
||||
.1
|
||||
.checked_add(1)
|
||||
.expect("bad_event_ratelimiter attempt/try count should not ever get this high"),
|
||||
);
|
||||
*e.get_mut() = (Instant::now(), e.get().1.saturating_add(1));
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -806,7 +806,9 @@ pub(crate) async fn upgrade_room_route(body: Ruma<upgrade_room::v3::Request>) ->
|
|||
power_levels_event_content
|
||||
.users_default
|
||||
.checked_add(int!(1))
|
||||
.expect("user power level should not be this high"),
|
||||
.ok_or_else(|| {
|
||||
Error::BadRequest(ErrorKind::BadJson, "users_default power levels event content is not valid")
|
||||
})?,
|
||||
);
|
||||
power_levels_event_content.events_default = new_level;
|
||||
power_levels_event_content.invite = new_level;
|
||||
|
|
|
@ -557,7 +557,7 @@ async fn handle_left_room(
|
|||
|
||||
left_state_events.push(pdu.to_sync_state_event());
|
||||
|
||||
i = i.saturating_add(1);
|
||||
i = i.wrapping_add(1);
|
||||
if i % 100 == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
@ -705,11 +705,7 @@ async fn load_joined_room(
|
|||
// Recalculate heroes (first 5 members)
|
||||
let mut heroes = Vec::new();
|
||||
|
||||
if joined_member_count
|
||||
.checked_add(invited_member_count)
|
||||
.expect("joined/invite member count should not be this high")
|
||||
<= 5
|
||||
{
|
||||
if joined_member_count.saturating_add(invited_member_count) <= 5 {
|
||||
// Go through all PDUs and for each member event, check if the user is still
|
||||
// joined or invited until we have 5 or we reach the end
|
||||
|
||||
|
@ -802,7 +798,7 @@ async fn load_joined_room(
|
|||
};
|
||||
state_events.push(pdu);
|
||||
|
||||
i = i.saturating_add(1);
|
||||
i = i.wrapping_add(1);
|
||||
if i % 100 == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
@ -823,7 +819,7 @@ async fn load_joined_room(
|
|||
}
|
||||
state_events.push(pdu);
|
||||
|
||||
i = i.saturating_add(1);
|
||||
i = i.wrapping_add(1);
|
||||
if i % 100 == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue