From 2893a168c61d0f1b7a72d5588e4223dff0143884 Mon Sep 17 00:00:00 2001 From: koe Date: Sun, 22 Dec 2024 16:04:30 -0600 Subject: [PATCH] use div_ceil --- renet2/src/channel/reliable.rs | 2 +- renet2/src/channel/unreliable.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/renet2/src/channel/reliable.rs b/renet2/src/channel/reliable.rs index 475e5049..96edd050 100644 --- a/renet2/src/channel/reliable.rs +++ b/renet2/src/channel/reliable.rs @@ -58,7 +58,7 @@ pub struct ReceiveChannelReliable { impl UnackedMessage { fn new_sliced(payload: Bytes) -> Self { - let num_slices = (payload.len() + SLICE_SIZE - 1) / SLICE_SIZE; + let num_slices = payload.len().div_ceil(SLICE_SIZE); Self::Sliced { message: payload, diff --git a/renet2/src/channel/unreliable.rs b/renet2/src/channel/unreliable.rs index 62f81377..8fb86086 100644 --- a/renet2/src/channel/unreliable.rs +++ b/renet2/src/channel/unreliable.rs @@ -63,7 +63,7 @@ impl SendChannelUnreliable { *available_bytes -= message.len() as u64; if message.len() > SLICE_SIZE { - let num_slices = (message.len() + SLICE_SIZE - 1) / SLICE_SIZE; + let num_slices = message.len().div_ceil(SLICE_SIZE); for slice_index in 0..num_slices { let start = slice_index * SLICE_SIZE;