Lint: clippy's collapsible_match passes on Rust 1.95
cargo +1.95 clippy --workspace --all-targets --release -- -D warnings
stopped on seven `if` blocks that clippy wants folded into their match
arm (psd, text, effects x2, pdf x2, render). Each becomes a match guard.
The behaviour is unchanged: when a guard is false the value falls through
to arms that can't match it and then to `_ => {}`. The one exception is
the PDF PostScript calculator, where a `{` past the nesting limit would
fall through to the operator arm; it keeps its own no-op arm, so it is
still skipped rather than pushed as an operator.
This commit is contained in:
parent
1446e27d85
commit
75cc264ccf
|
|
@ -245,10 +245,8 @@ pub fn process(id: &str, params: &Params, buf: &mut [f32], rate: u32, start: f64
|
||||||
}
|
}
|
||||||
let sr = rate as f64;
|
let sr = rate as f64;
|
||||||
match id {
|
match id {
|
||||||
"ec.audio.backwards" => {
|
"ec.audio.backwards" if params.b("swapChannels") => {
|
||||||
if params.b("swapChannels") {
|
buf.as_chunks_mut::<2>().0.iter_mut().for_each(|f| f.swap(0, 1));
|
||||||
buf.as_chunks_mut::<2>().0.iter_mut().for_each(|f| f.swap(0, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"ec.audio.basstreble" => {
|
"ec.audio.basstreble" => {
|
||||||
let bass = params.f("bass") / 100.0 * 12.0;
|
let bass = params.f("bass") / 100.0 * 12.0;
|
||||||
|
|
|
||||||
|
|
@ -503,10 +503,8 @@ fn scan_runs(polys: &[(Vec<[f64; 2]>, bool, bool)], fill: u32, ew: f64, d: [f64;
|
||||||
let entering = k % 2 == 0;
|
let entering = k % 2 == 0;
|
||||||
let l = ew / sin;
|
let l = ew / sin;
|
||||||
match mode {
|
match mode {
|
||||||
0 => {
|
0 if entering && k + 1 < xs.len() => {
|
||||||
if entering && k + 1 < xs.len() {
|
out.push((t, xs[k + 1].0));
|
||||||
out.push((t, xs[k + 1].0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
1 => out.push((t - l * 0.5, t + l * 0.5)),
|
1 => out.push((t - l * 0.5, t + l * 0.5)),
|
||||||
2 => out.push(if entering { (t, t + l) } else { (t - l, t) }),
|
2 => out.push(if entering { (t, t + l) } else { (t - l, t) }),
|
||||||
|
|
|
||||||
|
|
@ -221,11 +221,9 @@ fn ps_parse(lx: &mut crate::object::Lexer, depth: usize) -> Vec<PsOp> {
|
||||||
match o {
|
match o {
|
||||||
Obj::Num(n) => out.push(PsOp::Num(n)),
|
Obj::Num(n) => out.push(PsOp::Num(n)),
|
||||||
Obj::Bool(b) => out.push(PsOp::Num(if b { 1.0 } else { 0.0 })),
|
Obj::Bool(b) => out.push(PsOp::Num(if b { 1.0 } else { 0.0 })),
|
||||||
Obj::Op(op) if op == "{" => {
|
Obj::Op(op) if op == "{" && depth < 32 => out.push(PsOp::Proc(ps_parse(lx, depth + 1))),
|
||||||
if depth < 32 {
|
// Nested too deep: skip the procedure's opening brace (never push it as an operator).
|
||||||
out.push(PsOp::Proc(ps_parse(lx, depth + 1)));
|
Obj::Op(op) if op == "{" => {}
|
||||||
}
|
|
||||||
}
|
|
||||||
Obj::Op(op) if op == "}" => return out,
|
Obj::Op(op) if op == "}" => return out,
|
||||||
Obj::Op(op) => out.push(PsOp::Op(op)),
|
Obj::Op(op) => out.push(PsOp::Op(op)),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
|
|
@ -313,11 +313,9 @@ impl<'a> Interp<'a> {
|
||||||
self.path.curve_to(Point::new(n(0), n(1)), p, p);
|
self.path.curve_to(Point::new(n(0), n(1)), p, p);
|
||||||
self.cur = Some(p);
|
self.cur = Some(p);
|
||||||
}
|
}
|
||||||
"h" => {
|
"h" if self.cur.is_some() => {
|
||||||
if self.cur.is_some() {
|
self.path.close_path();
|
||||||
self.path.close_path();
|
self.cur = self.start;
|
||||||
self.cur = self.start;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"re" => {
|
"re" => {
|
||||||
let (x, y, w, h) = (n(0), n(1), n(2), n(3));
|
let (x, y, w, h) = (n(0), n(1), n(2), n(3));
|
||||||
|
|
|
||||||
|
|
@ -656,10 +656,8 @@ impl Psd {
|
||||||
let gamma = r.f32()? as f64;
|
let gamma = r.f32()? as f64;
|
||||||
l.adjustment = Some(Adjustment::Exposure { exposure, offset, gamma });
|
l.adjustment = Some(Adjustment::Exposure { exposure, offset, gamma });
|
||||||
}
|
}
|
||||||
b"curv" | b"blnc" | b"post" | b"thrs" | b"selc" | b"mixr" | b"phfl" | b"vibA" | b"blwh" | b"grdm" | b"clrL" => {
|
b"curv" | b"blnc" | b"post" | b"thrs" | b"selc" | b"mixr" | b"phfl" | b"vibA" | b"blwh" | b"grdm" | b"clrL" if l.adjustment.is_none() => {
|
||||||
if l.adjustment.is_none() {
|
l.adjustment = Some(Adjustment::Other(String::from_utf8_lossy(key).into_owned()));
|
||||||
l.adjustment = Some(Adjustment::Other(String::from_utf8_lossy(key).into_owned()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b"SoLd" | b"SoLE" => {
|
b"SoLd" | b"SoLE" => {
|
||||||
let _id = r.tag()?;
|
let _id = r.tag()?;
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,8 @@ pub fn shapes(ctx: &EvalCtx, layer: &Layer) -> Vec<effectcraft_effects::MaskShap
|
||||||
let mut pts: Vec<[f64; 2]> = Vec::new();
|
let mut pts: Vec<[f64; 2]> = Vec::new();
|
||||||
let mut closed = false;
|
let mut closed = false;
|
||||||
kurbo::flatten(path.iter(), 0.25, |el| match el {
|
kurbo::flatten(path.iter(), 0.25, |el| match el {
|
||||||
effectcraft_path::PathEl::MoveTo(p) | effectcraft_path::PathEl::LineTo(p) => {
|
effectcraft_path::PathEl::MoveTo(p) | effectcraft_path::PathEl::LineTo(p) if pts.last() != Some(&[p.x, p.y]) => {
|
||||||
if pts.last() != Some(&[p.x, p.y]) {
|
pts.push([p.x, p.y]);
|
||||||
pts.push([p.x, p.y]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
effectcraft_path::PathEl::ClosePath => closed = true,
|
effectcraft_path::PathEl::ClosePath => closed = true,
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,8 @@ impl PathMeasure {
|
||||||
pts.push(p);
|
pts.push(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PathEl::LineTo(p) => {
|
PathEl::LineTo(p) if pts.last().is_none_or(|q| q.distance(p) > 1e-9) => {
|
||||||
if pts.last().is_none_or(|q| q.distance(p) > 1e-9) {
|
pts.push(p);
|
||||||
pts.push(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PathEl::ClosePath => {
|
PathEl::ClosePath => {
|
||||||
closed = true;
|
closed = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue