nil/copy: Use saturating_sub() instead of doing it manually

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36849>
This commit is contained in:
Faith Ekstrand 2025-08-19 11:28:44 -04:00 committed by Marge Bot
parent fb04c68573
commit e6c32c7b92

View file

@ -321,11 +321,7 @@ fn chunk_range(
chunk_len: u32,
) -> Range<u32> {
debug_assert!(chunk_start < whole.end);
let start = if chunk_start < whole.start {
whole.start - chunk_start
} else {
0
};
let start = whole.start.saturating_sub(chunk_start);
let end = std::cmp::min(whole.end - chunk_start, chunk_len);
start..end
}