Skip to content

Commit 75ae20d

Browse files
committed
use std clamp instead of Bevy's (#1644)
Rust std's `clamp` has been stabilised in 1.50: rust-lang/rust#44095 This is already the minimum supported version, so no change there 👍
1 parent 785aad9 commit 75ae20d

File tree

4 files changed

+5
-29
lines changed

4 files changed

+5
-29
lines changed

crates/bevy_core/src/task_pool_options.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl TaskPoolThreadAssignmentPolicy {
2727
// Clamp by min_threads, max_threads. (This may result in us using more threads than are
2828
// available, this is intended. An example case where this might happen is a device with
2929
// <= 2 threads.
30-
bevy_math::clamp(desired, self.min_threads, self.max_threads)
30+
desired.clamp(self.min_threads, self.max_threads)
3131
}
3232
}
3333

@@ -94,11 +94,8 @@ impl DefaultTaskPoolOptions {
9494

9595
/// Inserts the default thread pools into the given resource map based on the configured values
9696
pub fn create_default_pools(&self, world: &mut World) {
97-
let total_threads = bevy_math::clamp(
98-
bevy_tasks::logical_core_count(),
99-
self.min_total_threads,
100-
self.max_total_threads,
101-
);
97+
let total_threads =
98+
bevy_tasks::logical_core_count().clamp(self.min_total_threads, self.max_total_threads);
10299
trace!("Assigning {} cores to default task pools", total_threads);
103100

104101
let mut remaining_threads = total_threads;

crates/bevy_math/src/clamp.rs

-19
This file was deleted.

crates/bevy_math/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
mod clamp;
21
mod face_toward;
32
mod geometry;
43

5-
pub use clamp::*;
64
pub use face_toward::*;
75
pub use geometry::*;
86
pub use glam::*;

crates/bevy_sprite/src/texture_atlas_builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ impl TextureAtlasBuilder {
177177
Some(rect_placements)
178178
}
179179
Err(rectangle_pack::RectanglePackError::NotEnoughBinSpace) => {
180-
current_height = bevy_math::clamp(current_height * 2, 0, max_height);
181-
current_width = bevy_math::clamp(current_width * 2, 0, max_width);
180+
current_height = (current_height * 2).clamp(0, max_height);
181+
current_width = (current_width * 2).clamp(0, max_width);
182182
None
183183
}
184184
};

0 commit comments

Comments
 (0)