break loop early on 0 curr strain

This commit is contained in:
MaxOhn
2023-02-09 14:04:28 +01:00
parent 68050f7848
commit 7cc3a4644b
11 changed files with 58 additions and 28 deletions
+1 -3
View File
@@ -102,11 +102,9 @@ impl<'map> OsuStars<'map> {
/// Adjust the clock rate used in the calculation.
/// If none is specified, it will take the clock rate based on the mods
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
///
/// The value cannot go below 0.001.
#[inline]
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
self.clock_rate = Some(clock_rate.max(0.001));
self.clock_rate = Some(clock_rate);
self
}
+1 -3
View File
@@ -172,11 +172,9 @@ impl<'map> OsuPP<'map> {
/// Adjust the clock rate used in the calculation.
/// If none is specified, it will take the clock rate based on the mods
/// i.e. 1.5 for DT, 0.75 for HT and 1.0 otherwise.
///
/// The value cannot go below 0.001.
#[inline]
pub fn clock_rate(mut self, clock_rate: f64) -> Self {
self.clock_rate = Some(clock_rate.max(0.001));
self.clock_rate = Some(clock_rate);
self
}
+12
View File
@@ -47,6 +47,18 @@ pub(crate) trait StrainSkill: Skill + Sized {
}
*self.curr_section_end() += SECTION_LEN;
// Optimization to finish the loop early if
// the current peak is 0.0 i.e. it can't decay further.
// If final values don't coincide perfectly anymore,
// this should be looked at and maybe adjusted.
if self.curr_section_peak().abs() <= f64::EPSILON
&& curr.start_time > *self.curr_section_end()
{
let remaining = curr.start_time - *self.curr_section_end();
let skip_iter_count = (remaining / SECTION_LEN).ceil();
*self.curr_section_end() += skip_iter_count * SECTION_LEN;
}
}
*self.curr_section_peak() = self