From a02481a5d941b22041796e6ebdf2565319c48508 Mon Sep 17 00:00:00 2001 From: Beinsezii Date: Wed, 26 Jun 2024 15:29:59 -0700 Subject: [PATCH] cielab_to_xyz 70% perf improvement yay fma --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 02c629b..f9eb28f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1329,10 +1329,11 @@ pub fn cielab_to_xyz(pixel: &mut [T; N]) where Channels: ValidChannels, { + pixel[0] = pixel[0].fma((1.0 / 116.0).to_dt(), (16.0 / 116.0).to_dt()); [pixel[0], pixel[1], pixel[2]] = [ - (pixel[0] + 16.0.to_dt()) / 116.0.to_dt() + pixel[1] / 500.0.to_dt(), - (pixel[0] + 16.0.to_dt()) / 116.0.to_dt(), - (pixel[0] + 16.0.to_dt()) / 116.0.to_dt() - pixel[2] / 200.0.to_dt(), + pixel[0] + pixel[1] / 500.0.to_dt(), + pixel[0], + pixel[0] - pixel[2] / 200.0.to_dt(), ]; pixel.iter_mut().take(3).for_each(|c| {