use std clamp instead of Bevy's (#1644)
Rust std's `clamp` has been stabilised in 1.50: https://github.com/rust-lang/rust/issues/44095 This is already the minimum supported version, so no change there 👍
This commit is contained in:
parent
785aad92f4
commit
75ae20dc4a
@ -27,7 +27,7 @@ impl TaskPoolThreadAssignmentPolicy {
|
||||
// Clamp by min_threads, max_threads. (This may result in us using more threads than are
|
||||
// available, this is intended. An example case where this might happen is a device with
|
||||
// <= 2 threads.
|
||||
bevy_math::clamp(desired, self.min_threads, self.max_threads)
|
||||
desired.clamp(self.min_threads, self.max_threads)
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,11 +94,8 @@ impl DefaultTaskPoolOptions {
|
||||
|
||||
/// Inserts the default thread pools into the given resource map based on the configured values
|
||||
pub fn create_default_pools(&self, world: &mut World) {
|
||||
let total_threads = bevy_math::clamp(
|
||||
bevy_tasks::logical_core_count(),
|
||||
self.min_total_threads,
|
||||
self.max_total_threads,
|
||||
);
|
||||
let total_threads =
|
||||
bevy_tasks::logical_core_count().clamp(self.min_total_threads, self.max_total_threads);
|
||||
trace!("Assigning {} cores to default task pools", total_threads);
|
||||
|
||||
let mut remaining_threads = total_threads;
|
||||
|
@ -1,19 +0,0 @@
|
||||
/// A value bounded by a minimum and a maximum
|
||||
///
|
||||
/// If input is less than min then this returns min.
|
||||
/// If input is greater than max then this returns max.
|
||||
/// Otherwise this returns input.
|
||||
///
|
||||
/// **Panics** in debug mode if `!(min <= max)`.
|
||||
///
|
||||
/// Original implementation from num-traits licensed as MIT
|
||||
pub fn clamp<T: PartialOrd>(input: T, min: T, max: T) -> T {
|
||||
debug_assert!(min <= max, "min must be less than or equal to max");
|
||||
if input < min {
|
||||
min
|
||||
} else if input > max {
|
||||
max
|
||||
} else {
|
||||
input
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
mod clamp;
|
||||
mod face_toward;
|
||||
mod geometry;
|
||||
|
||||
pub use clamp::*;
|
||||
pub use face_toward::*;
|
||||
pub use geometry::*;
|
||||
pub use glam::*;
|
||||
|
@ -177,8 +177,8 @@ impl TextureAtlasBuilder {
|
||||
Some(rect_placements)
|
||||
}
|
||||
Err(rectangle_pack::RectanglePackError::NotEnoughBinSpace) => {
|
||||
current_height = bevy_math::clamp(current_height * 2, 0, max_height);
|
||||
current_width = bevy_math::clamp(current_width * 2, 0, max_width);
|
||||
current_height = (current_height * 2).clamp(0, max_height);
|
||||
current_width = (current_width * 2).clamp(0, max_width);
|
||||
None
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user