From 472ed3e4e50a165638acecaf071ec3c2c13c451f Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 23:27:41 +0300 Subject: core: optimize struct layouts, eliminate branches, and fix event loop dispatch - Fix Wayland event loop lockout by properly decoupling read arming and adding poll-backed dispatching - Support standalone display lifecycle without requiring caller to manage a loop - Eliminate alignment holes across yasl_surface, yasl_display, seat, touch_point, and conn_drag using pahole - Replace branching state/button decoders with compile-time locked LUTs and branchless bitwise operations - Accelerate UTF-8 validation with 64-bit word scanning for ASCII runs --- src/common/timing.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/common/timing.c') diff --git a/src/common/timing.c b/src/common/timing.c index b5e342f..3e3a705 100644 --- a/src/common/timing.c +++ b/src/common/timing.c @@ -5,8 +5,8 @@ uint64_t yasl_clock_extend_ms(uint32_t ms, uint64_t now_ns) uint64_t now_ms = now_ns / 1000000; int64_t ahead = (int32_t)(ms - (uint32_t)now_ms); if (ahead < 0 && (uint64_t)-ahead > now_ms) - return (uint64_t)ms * 1000000; - return (now_ms + (uint64_t)ahead) * 1000000; + return (uint64_t)ms * 1000000ull; + return (uint64_t)((int64_t)now_ms + ahead) * 1000000ull; } void yasl_clock_presented(struct yasl_frame_clock *c, uint64_t now, bool sample) @@ -45,9 +45,8 @@ double yasl_clock_refresh_ms(const struct yasl_frame_clock *c) uint64_t yasl_clock_next_present_ns(const struct yasl_frame_clock *c) { - return c->last_present_ns - ? c->last_present_ns + (uint64_t)c->refresh_ns - : 0; + uint64_t next = c->last_present_ns + (uint64_t)c->refresh_ns; + return (uint64_t)-(c->last_present_ns != 0) & next; } uint64_t yasl_clock_frame_timestamp_ns(struct yasl_frame_clock *c, uint64_t now) -- cgit v1.2.3