share CurvePointIter between features again

This commit is contained in:
MaxOhn
2021-01-26 18:53:26 +01:00
parent 07bf677982
commit 54a056e36a
2 changed files with 7 additions and 29 deletions
+6 -28
View File
@@ -37,7 +37,7 @@ impl<'p> ControlPointIter<'p> {
pub(crate) enum ControlPoint {
Timing {
time: f32,
#[cfg(not(feature = "no_sliders_no_leniency"))]
#[allow(dead_code)]
beat_len: f32,
},
Difficulty {
@@ -46,9 +46,9 @@ pub(crate) enum ControlPoint {
},
}
#[cfg(not(feature = "no_sliders_no_leniency"))]
impl ControlPoint {
#[inline]
#[allow(dead_code)]
pub(crate) fn time(&self) -> f32 {
match self {
Self::Timing { time, .. } => *time,
@@ -62,21 +62,10 @@ impl<'p> Iterator for ControlPointIter<'p> {
fn next(&mut self) -> Option<Self::Item> {
match (self.next_timing, self.next_difficulty) {
(Some((time, _beat_len)), Some((d, _))) if time <= d => {
(Some((time, beat_len)), Some((d, _))) if time <= d => {
self.next_timing = next_tuple!(self.timing_points, (time, beat_len));
#[cfg(not(feature = "no_sliders_no_leniency"))]
{
Some(ControlPoint::Timing {
time,
beat_len: _beat_len,
})
}
#[cfg(feature = "no_sliders_no_leniency")]
{
Some(ControlPoint::Timing { time })
}
Some(ControlPoint::Timing { time, beat_len })
}
(_, Some((time, speed_mult))) => {
self.next_difficulty =
@@ -84,21 +73,10 @@ impl<'p> Iterator for ControlPointIter<'p> {
Some(ControlPoint::Difficulty { time, speed_mult })
}
(Some((time, _beat_len)), None) => {
(Some((time, beat_len)), None) => {
self.next_timing = next_tuple!(self.timing_points, (time, beat_len));
#[cfg(not(feature = "no_sliders_no_leniency"))]
{
Some(ControlPoint::Timing {
time,
beat_len: _beat_len,
})
}
#[cfg(feature = "no_sliders_no_leniency")]
{
Some(ControlPoint::Timing { time })
}
Some(ControlPoint::Timing { time, beat_len })
}
(None, None) => None,
}
@@ -29,7 +29,7 @@ impl<'p> SliderState<'p> {
self.px_per_beat = map.sv * 100.0 * self.prev_sv;
match self.control_points.next() {
Some(ControlPoint::Timing { time }) => {
Some(ControlPoint::Timing { time, .. }) => {
self.next_time = time;
self.prev_sv = 1.0;
}