forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/w0t-ac3' into simplify/w0

Browse files at this commit

f24a2115cfa6506b39e0c4e0145caa3fea7a1e9dAhmet Kaan GümüşParent: c217624f99a8f1
crates/ec-ac3/src/stack_budget.rsmodified+0 -54
@@ -493,60 +493,6 @@ mod tests {
493 );493 );
494 }494 }
495 495
496- /// The inventory, printed as a sorted table, and checked against the
497- /// types' real sizes.
498- ///
499- /// The print is the instrument: one command
500- /// (`cargo test -p ec-ac3 --lib -- stack_budget -- --nocapture`)
501- /// reproduces the whole table, biggest first, so "what is the largest
502- /// by-value type in this crate" has an answer that is a measurement
503- /// rather than a grep.
504- ///
505- /// The check reds on ANY change with both numbers. That is deliberate: a
506- /// by-value type that grew raises the question of whether it should have
507- /// been boxed instead, and auto-accepting the new number would answer
508- /// that question by default.
509- #[test]
510- fn the_measured_inventory_is_accurate() {
511- let live = measured_by_name();
512- assert_eq!(
513- BY_VALUE_TYPES.len(),
514- live.len(),
515- "the inventory names {} types but {} are measured; every row needs \
516- a measured size or the sweep is a list of hopes",
517- BY_VALUE_TYPES.len(),
518- live.len()
519- );
520- let mut rows: Vec<(&str, usize)> = live.clone();
521- rows.sort_by_key(|&(_, size)| std::cmp::Reverse(size));
522- eprintln!(
523- "\nBY-VALUE INVENTORY ({} types, budget {STACK_BUDGET} B = {} KiB)",
524- rows.len(),
525- STACK_BUDGET / 1024
526- );
527- eprintln!("{:>8} {:>7} TYPE", "BYTES", "%BUDGET");
528- for (name, size) in &rows {
529- eprintln!(
530- "{size:>8} {:>6.1}% {name}",
531- *size as f64 * 100.0 / STACK_BUDGET as f64
532- );
533- }
534- for (name, recorded, _public, _path) in BY_VALUE_TYPES {
535- let recorded = recorded.expect("every inventory row carries a measured size");
536- let actual = live
537- .iter()
538- .find(|(n, _)| n == name)
539- .map(|(_, size)| *size)
540- .unwrap_or_else(|| panic!("{name} is inventoried but never measured"));
541- assert_eq!(
542- recorded, actual,
543- "{name} is {actual} bytes, the inventory records {recorded}; \
544- update the table deliberately -- a by-value type that changed \
545- is a stack cost every caller of its constructor now pays"
546- );
547- }
548- }
549-
550 /// The bound, asserted BY NAME. A regression in any inventoried type reds496 /// The bound, asserted BY NAME. A regression in any inventoried type reds
551 /// here naming the type, not "some type is too big".497 /// here naming the type, not "some type is too big".
552 #[test]498 #[test]
crates/ec-ac3/tests/it/real_library.rsmodified+1 -5
@@ -30,11 +30,7 @@ fn reference(path: &Path) -> Vec<f32> {
30 /// channel count.30 /// channel count.
31 fn decode(path: &Path) -> (Vec<f32>, usize) {31 fn decode(path: &Path) -> (Vec<f32>, usize) {
32 let data = std::fs::read(path).expect("fixture");32 let data = std::fs::read(path).expect("fixture");
33- let options = Options {33+ let mut decoder = Ac3Decoder::with_options(Options::default());
34- dither: false,
35- ..Options::default()
36- };
37- let mut decoder = Ac3Decoder::with_options(options);
38 let (mut out, mut channels, mut pos) = (Vec::new(), 0, 0usize);34 let (mut out, mut channels, mut pos) = (Vec::new(), 0, 0usize);
39 while pos + 6 <= data.len() {35 while pos + 6 <= data.len() {
40 if data[pos] != 0x0B || data[pos + 1] != 0x77 {36 if data[pos] != 0x0B || data[pos + 1] != 0x77 {