Use Bytes as the Container of ImageBuffer

Since we don't need to mutate images once loaded,
we avoid unnecessary extra allocations.
This commit is contained in:
Héctor Ramón Jiménez 2024-05-01 00:55:49 +02:00
parent 7c084d9695
commit 45254ab88c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 105 additions and 109 deletions

View file

@ -83,7 +83,7 @@ impl Cache {
let id = handle.id();
if let hash_map::Entry::Vacant(entry) = self.entries.entry(id) {
let image = graphics::image::load(handle).ok()?.into_rgba8();
let image = graphics::image::load(handle).ok()?;
let mut buffer =
vec![0u32; image.width() as usize * image.height() as usize];