diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-06-16 20:11:56 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-06-16 20:11:56 -0700 |
commit | f1d5b79982f02c62539da2505cb8a4cd402d4969 (patch) | |
tree | 1cfa8562050f401aff82c573cb3060b9b8805440 /src | |
parent | deb98475a01a5e62d39109e9b703b567612260da (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/moire/moire.c | 3 |
1 files changed, 1 insertions, 2 deletions
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) |