Calculate exact capacity needed for hash

This commit is contained in:
asonix 2024-03-06 13:27:03 -06:00
parent e1c57d1930
commit e5efa1e4f8

View file

@ -358,11 +358,11 @@ impl Encoder {
}
}
let mut blurhash = String::with_capacity(30);
let (_, dc) = self.factors[0];
let ac = &self.factors[1..];
let mut blurhash = String::with_capacity(1 + 1 + 4 + 2 * ac.len());
let size_flag = self.components.x - 1 + (self.components.y - 1) * 9;
base83::encode(size_flag, 1, &mut blurhash);