From 5530c662bb53837d64a154e3b580d41adb6cc8b9 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 23:30:21 +0300 Subject: opt: compile-time locked LUTs and branchless SIMD/ALU primitives - Replace buffer allocation branching loop with compile-time locked 24-byte LUT indexed by (cur & 3) - Use hardware lrint rounding and array-indexed pointer offsets for scroll axes - Replace press queue button/kind conditionals with branchless bitmasking and 1:1 identity casting - Make display_has_immediate_work evaluate state flags with bitwise ALU instead of short-circuit branches --- src/wayland/surface.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/wayland/surface.c') diff --git a/src/wayland/surface.c b/src/wayland/surface.c index 5138201..86f30a3 100644 --- a/src/wayland/surface.c +++ b/src/wayland/surface.c @@ -123,14 +123,13 @@ static bool display_arm(struct yasl_display *c) return had_pending; } -static bool display_has_immediate_work(const struct yasl_display *c) +static inline bool display_has_immediate_work(const struct yasl_display *c) { - if (!c || c->lost) return false; + if (unlikely(!c || c->lost)) return false; for (struct yasl_surface *w = c->surfaces; w; w = w->conn_next) { - if (w->closed) continue; - if (w->input.count > 0) - return true; - if (w->want_draw && !w->frame_cb && w->configured) + bool ready_draw = w->want_draw & (w->frame_cb == NULL) & w->configured; + bool has_input = (w->input.count > 0); + if (unlikely((ready_draw | has_input) & !w->closed)) return true; } return false; -- cgit v1.2.3