From f1d5b79982f02c62539da2505cb8a4cd402d4969 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 16 Jun 2023 20:11:56 -0700 Subject: modules/moire: lose unnecessary branch in inner loop I had benchmarked this change and it showed no difference at all on my 2c/4c i7 X230. But having just tried it on an RPi4B where it moved the test case from 54FPS to 60FPS, a +10% improvement, it's worth the readability loss. It's interesting how Intel's cleverness discourages optimizing in ways that benefit probably *all* the competition... even when the optimization is such a minor change in terms of effort. --- src/modules/moire/moire.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/modules/moire') diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c index 973fbee..a06549c 100644 --- a/src/modules/moire/moire.c +++ b/src/modules/moire/moire.c @@ -101,8 +101,7 @@ static void moire_render_fragment(til_module_context_t *context, til_stream_t *s dx = cx - centers[i].x; dy = cy - centers[i].y; - if ((int)((sqrtf(dx * dx + dy * dy)) * 20.f) % 2) - filled ^= 1; + filled ^= ((int)((sqrtf(dx * dx + dy * dy)) * 20.f) & 0x1); } if (filled) -- cgit v1.2.1