Bits2pulses row-window bound becomes a debug_assert (reviewer P3) - statically decidable from the unchanged CACHE_BITS table
Browse files at this commit70ebc1759a21dbe9480ffa3f4b08a4d5aed462cbParent: e7bf696- refactor
- bits2pulses row-window bound becomes a debug_assert (reviewer P3) - statically decidable from the unchanged CACHE_BITS table
- the fixed-window copy still panics if the table ever outgrew it
1 changed file +3 -1
crates/ec-opus/src/celt.rsmodified+3 -1
| @@ -2750,7 +2750,9 @@ const CACHE_ROW_MAX: usize = 64; | |||
| 2750 | pub(crate) fn bits2pulses(band: usize, lm: i32, bits: i32) -> i32 { | 2750 | pub(crate) fn bits2pulses(band: usize, lm: i32, bits: i32) -> i32 { |
| 2751 | let base = cache_index(band, lm); | 2751 | let base = cache_index(band, lm); |
| 2752 | let count = CACHE_BITS[base] as usize; | 2752 | let count = CACHE_BITS[base] as usize; |
| 2753 | - assert!( | 2753 | + // Statically decidable from the unchanged CACHE_BITS table (reviewer P3); |
| 2754 | + // the copy below still panics if the table ever outgrew the window. | ||
| 2755 | + debug_assert!( | ||
| 2754 | count < CACHE_ROW_MAX, | 2756 | count < CACHE_ROW_MAX, |
| 2755 | "CACHE_BITS row overflows the fixed window" | 2757 | "CACHE_BITS row overflows the fixed window" |
| 2756 | ); | 2758 | ); |