Removed branching

This commit is contained in:
MaxOhn
2021-01-08 12:26:59 +01:00
parent 0d72f28fc7
commit 238e33c660
9 changed files with 21 additions and 42 deletions
+8 -11
View File
@@ -58,18 +58,15 @@ impl<T: PartialOrd> LimitedQueue<T> {
pub(crate) fn min(&self) -> Option<&T> {
let mut iter = self.queue.iter();
if let Some(first) = iter.next() {
let min = iter.fold(first, |min, next| match min.partial_cmp(next) {
Some(Ordering::Less) => min,
Some(Ordering::Equal) => min,
Some(Ordering::Greater) => next,
None => min,
});
let first = iter.next()?;
let min = iter.fold(first, |min, next| match min.partial_cmp(next) {
Some(Ordering::Less) => min,
Some(Ordering::Equal) => min,
Some(Ordering::Greater) => next,
None => min,
});
Some(min)
} else {
None
}
Some(min)
}
}
+2
View File
@@ -69,6 +69,7 @@ impl Skill {
#[inline]
fn skill_multiplier(&self) -> f32 {
// TODO: Use constants
match self.kind {
SkillKind::Color { .. } => 1.0,
SkillKind::Rhythm { .. } => 10.0,
@@ -78,6 +79,7 @@ impl Skill {
#[inline]
fn strain_decay_base(&self) -> f32 {
// TODO: Use constants
match self.kind {
SkillKind::Color { .. } => 0.4,
SkillKind::Rhythm { .. } => 0.0,
+1
View File
@@ -12,6 +12,7 @@ pub(crate) trait StaminaCheeseDetector {
}
impl StaminaCheeseDetector for Beatmap {
// TODO: Optimize
fn find_cheese(&self) -> Vec<bool> {
let mut cheese = vec![false; self.hit_objects.len()];