From d278a85696f9cd2f0bf371a1dcd81f3099ba18cf Mon Sep 17 00:00:00 2001 From: xsvm <2479667226@qq.com> Date: Wed, 21 Oct 2026 11:26:21 +0800 Subject: [PATCH] Compose: tone and hue-range lookups truncate instead of calling floor Baseline x86-64 has no SSE4.1 roundss, so f32::floor is an out-of-line libm call there. lut, which every Levels, Curves, Hue/Saturation range and modern Brightness/Contrast sample goes through, floored its non-negative table position. Truncating is the same there (NaN casts to 0 either way) and inlines. Bit-identical. --- crates/compose/src/adjust.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/compose/src/adjust.rs b/crates/compose/src/adjust.rs index 38e34fcd12..a742876de1 100644 --- a/crates/compose/src/adjust.rs +++ b/crates/compose/src/adjust.rs @@ -898,7 +898,9 @@ fn map_rgb(buf: &mut Buffer, f: impl Fn([f32; 3]) -> [f32; 3]) { #[inline] fn lut(table: &[f32], v: f32) -> f32 { let x = v.clamp(0.0, 1.0) * (table.len() - 1) as f32; - let i = x.floor() as usize; + // Never negative (NaN casts to 0, as its floor did), so truncating is `floor`, without the + // libm call baseline x86-64 (no SSE4.1) makes for it. + let i = x as usize; let j = (i + 1).min(table.len() - 1); let f = x - i as f32; table[i] * (1.0 - f) + table[j] * f