use cmp methods

This commit is contained in:
MaxOhn
2024-02-26 18:07:16 +01:00
parent c2c617ec01
commit e81c0e890f
15 changed files with 76 additions and 48 deletions
@@ -1,3 +1,5 @@
use std::cmp;
use rosu_map::section::hit_objects::{hit_samples::HitSoundType, BorrowedCurve};
use crate::{
@@ -188,7 +190,7 @@ impl<'h> DistanceObjectPatternGenerator<'h> {
self.inner.total_columns - random_start - self.prev_pattern.column_with_objs();
let mut next_column = self.inner.get_random_column(None, None);
for _ in 0..usable_columns.min(note_count) {
for _ in 0..cmp::min(usable_columns, note_count) {
// * Find available column
next_column =
self.find_available_column(next_column, None, &[&pattern, self.prev_pattern]);
@@ -384,7 +386,7 @@ impl<'h> DistanceObjectPatternGenerator<'h> {
// * □ ■ - -
// * ■ - - -
let column_repeat = self.span_count.min(self.inner.total_columns) as usize;
let column_repeat = cmp::min(self.span_count, self.inner.total_columns) as usize;
// * Due to integer rounding, this is not guaranteed to be the same as EndTime (the class-level variable).
let end_time = start_time + self.segment_duration * self.span_count;
@@ -457,7 +459,7 @@ impl<'h> DistanceObjectPatternGenerator<'h> {
0
};
note_count = note_count.min(self.inner.total_columns - 1);
note_count = cmp::min(note_count, self.inner.total_columns - 1);
let sample = self.sample_info_list_at(start_time);
let ignore_head =
@@ -1,3 +1,5 @@
use std::cmp;
use rosu_map::section::hit_objects::hit_samples::HitSoundType;
use crate::{
@@ -239,10 +241,12 @@ impl<'h> HitObjectPatternGenerator<'h> {
let allow_stacking = !self.convert_type.contains(PatternType::FORCE_NOT_STACK);
if !allow_stacking {
note_count = (self.inner.total_columns
- self.inner.random_start()
- self.prev_pattern.column_with_objs())
.min(note_count);
note_count = cmp::min(
self.inner.total_columns
- self.inner.random_start()
- self.prev_pattern.column_with_objs(),
note_count,
);
}
let mut next_column = self.inner.get_column(Some(true));
+3 -1
View File
@@ -1,3 +1,5 @@
use std::cmp;
use crate::{
any::difficulty::skills::Skill,
mania::{object::ObjectParams, ManiaBeatmap},
@@ -159,7 +161,7 @@ impl Iterator for ManiaGradualDifficulty {
.zip(self.objects_is_circle.iter().skip(1))
.skip(self.idx.saturating_sub(1));
let mut take = n.min(self.len().saturating_sub(1));
let mut take = cmp::min(n, self.len().saturating_sub(1));
// The first note has no difficulty object
if self.idx == 0 && take > 0 {
+6 -3
View File
@@ -1,3 +1,5 @@
use std::cmp;
use crate::{
any::difficulty::{mode::ModeDifficulty, skills::Skill},
mania::{
@@ -19,9 +21,10 @@ pub fn difficulty(
difficulty: &ModeDifficulty,
converted: &ManiaBeatmap<'_>,
) -> ManiaDifficultyAttributes {
let n_objects = difficulty
.get_passed_objects()
.min(converted.map.hit_objects.len()) as u32;
let n_objects = cmp::min(
difficulty.get_passed_objects(),
converted.map.hit_objects.len(),
) as u32;
let values = DifficultyValues::calculate(difficulty, converted);
+14 -14
View File
@@ -256,8 +256,8 @@ impl<'map> ManiaPerformance<'map> {
let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -301,8 +301,8 @@ impl<'map> ManiaPerformance<'map> {
let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -346,8 +346,8 @@ impl<'map> ManiaPerformance<'map> {
let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -394,8 +394,8 @@ impl<'map> ManiaPerformance<'map> {
cmp::min(n_remaining, n320 + n300),
cmp::min(n_remaining, n320 + n300),
),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -457,8 +457,8 @@ impl<'map> ManiaPerformance<'map> {
cmp::min(n_remaining, n320 + n300),
cmp::min(n_remaining, n320 + n300),
),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -520,8 +520,8 @@ impl<'map> ManiaPerformance<'map> {
cmp::min(n_remaining, n320 + n300),
cmp::min(n_remaining, n320 + n300),
),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};
@@ -595,8 +595,8 @@ impl<'map> ManiaPerformance<'map> {
cmp::min(n_remaining, n320 + n300),
cmp::min(n_remaining, n320 + n300),
),
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(Some(_), None) => (cmp::max(min_n3x0, n320), cmp::max(max_n3x0, n320)),
(None, Some(_)) => (cmp::max(min_n3x0, n300), cmp::max(max_n3x0, n300)),
(None, None) => (min_n3x0, max_n3x0),
};