From 12ed34dcf9ff0bea6f33730548dbba63ea0e85d8 Mon Sep 17 00:00:00 2001 From: Devon Sawatsky Date: Mon, 27 Sep 2021 22:27:45 -0700 Subject: remove cache --- src/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7b2ae62..c257dea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,15 +23,9 @@ fn main() { let selected_colors = quantize(image.pixels()); - let mut color_map: HashMap, Rgb> = HashMap::with_capacity(image.len() / 2); - // Selected colors are themselves - for color in selected_colors.iter() { - color_map.insert(*color, *color); - } - // Max complexity is O(n * max_colors) for color in image.pixels_mut() { - let quantized = color_map.entry(*color).or_insert({ + let quantized = { let mut min_difference = f32::MAX; let mut min_difference_color = *color; @@ -43,9 +37,9 @@ fn main() { } } min_difference_color - }); + }; - *color = *quantized; + *color = quantized; } image.save(outname).expect("Failed to write out"); -- cgit 1.4.1-3-g733a5