Compare commits

...

2 commits

Author SHA1 Message Date
asonix b1cefd7863 Add length assertion
All checks were successful
/ tests (push) Successful in 2m32s
/ check (x86_64-unknown-linux-musl) (push) Successful in 6s
/ clippy (push) Successful in 8s
/ check (aarch64-unknown-linux-musl) (push) Successful in 7s
/ check (armv7-unknown-linux-musleabihf) (push) Successful in 6s
2024-02-18 13:25:39 -06:00
asonix 8f79825c2e Initialize blurhash string with some capacity 2024-02-18 13:20:05 -06:00

View file

@ -122,6 +122,7 @@ impl Encoder {
for (ComponentState { x, y, .. }, rgb) in self.factors.iter_mut() {
let basis = f32::cos(*x as f32 * scale_x) * f32::cos(*y as f32 * scale_y);
assert_eq!(chunk.len(), rgb.len());
for (val, slot) in chunk
.iter()
.map(|byte| basis * srgb_to_linear(*byte))
@ -168,7 +169,7 @@ impl Encoder {
}
}
let mut blurhash = String::new();
let mut blurhash = String::with_capacity(30);
let (_, dc) = self.factors[0];
let ac = &self.factors[1..];