refactor: fix all compiler + clippy warnings
- analysis.rs: use .clamp() instead of .max().min(), saturating_sub, inline corner_start into corner_start_s (dead assignment removed) - binary_utils.rs, parser_pcars.rs: use std::array::from_fn for array reads - recording.rs: std::io::Error::other() instead of Error::new(ErrorKind::Other), #[allow(dead_code)] on diagnostic methods (len, total_pushed, dropped_count, ring_stats) - track_model.rs: prefix unused path vars with _, #[allow(dead_code)] on exists() - parser_ksudp.rs: fix doc list item indentation - session.rs: std::mem::take instead of mem::replace(..., Default::default()) cargo build: 0 warnings, clippy: 0 warnings, 33 tests pass
This commit is contained in:
parent
9a4ca18864
commit
d86a87ab7d
7 changed files with 21 additions and 29 deletions
|
|
@ -116,7 +116,7 @@ pub fn analyze_shift_points(
|
|||
|
||||
points.sort_by(|a, b| a.speed_kmh.partial_cmp(&b.speed_kmh).unwrap_or(std::cmp::Ordering::Equal));
|
||||
|
||||
let window = (points.len() / 5).max(3).min(15);
|
||||
let window = (points.len() / 5).clamp(3, 15);
|
||||
let acc_values: Vec<f32> = points.iter().map(|p| p.acceleration_g).collect();
|
||||
let smoothed = smooth(&acc_values, window);
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ fn smooth(values: &[f32], window: usize) -> Vec<f32> {
|
|||
let n = values.len();
|
||||
let mut result = Vec::with_capacity(n);
|
||||
for i in 0..n {
|
||||
let start = if i >= half { i - half } else { 0 };
|
||||
let start = i.saturating_sub(half);
|
||||
let end = (i + half + 1).min(n);
|
||||
let sum: f32 = values[start..end].iter().sum();
|
||||
result.push(sum / (end - start) as f32);
|
||||
|
|
@ -588,7 +588,7 @@ pub fn build_track_model(
|
|||
curvature.push(0.0);
|
||||
|
||||
// Step 7: Smooth curvature
|
||||
let window = (curvature.len() / 50).min(21).max(3);
|
||||
let window = (curvature.len() / 50).clamp(3, 21);
|
||||
let smoothed_curvature = smooth_f64(&curvature, window);
|
||||
|
||||
// Step 8: Auto-detect corners
|
||||
|
|
@ -665,7 +665,7 @@ fn smooth_f64(values: &[f64], window: usize) -> Vec<f64> {
|
|||
let n = values.len();
|
||||
let mut result = Vec::with_capacity(n);
|
||||
for i in 0..n {
|
||||
let start = if i >= half { i - half } else { 0 };
|
||||
let start = i.saturating_sub(half);
|
||||
let end = (i + half + 1).min(n);
|
||||
let sum: f64 = values[start..end].iter().sum();
|
||||
result.push(sum / (end - start) as f64);
|
||||
|
|
@ -676,7 +676,6 @@ fn smooth_f64(values: &[f64], window: usize) -> Vec<f64> {
|
|||
fn detect_corners(curvature: &[f64]) -> Vec<Corner> {
|
||||
let mut corners = Vec::new();
|
||||
let mut in_corner = false;
|
||||
let mut corner_start = 0usize;
|
||||
let mut corner_start_s = 0.0f64;
|
||||
let mut peak_idx = 0usize;
|
||||
let mut peak_kappa = 0.0f64;
|
||||
|
|
@ -688,8 +687,7 @@ fn detect_corners(curvature: &[f64]) -> Vec<Corner> {
|
|||
let abs_k = k.abs();
|
||||
if abs_k > CORNER_THRESHOLD && !in_corner {
|
||||
in_corner = true;
|
||||
corner_start = i.saturating_sub(5);
|
||||
corner_start_s = corner_start as f64 / denom;
|
||||
corner_start_s = i.saturating_sub(5) as f64 / denom;
|
||||
peak_idx = i;
|
||||
peak_kappa = abs_k;
|
||||
} else if abs_k > peak_kappa && in_corner {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue