Skip to content

Commit

Permalink
use std clamp instead of Bevy's (#1644)
Browse files Browse the repository at this point in the history
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 👍
  • Loading branch information
mockersf committed Mar 13, 2021
1 parent 785aad9 commit 75ae20d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
9 changes: 3 additions & 6 deletions crates/bevy_core/src/task_pool_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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;
Expand Down
19 changes: 0 additions & 19 deletions crates/bevy_math/src/clamp.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/bevy_math/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mod clamp;
mod face_toward;
mod geometry;

pub use clamp::*;
pub use face_toward::*;
pub use geometry::*;
pub use glam::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/texture_atlas_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down

0 comments on commit 75ae20d

Please sign in to comment.