diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 23:27:41 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 23:27:41 +0300 |
| commit | 472ed3e4e50a165638acecaf071ec3c2c13c451f (patch) | |
| tree | d1894debde800d8e87d3c242ae6c3f4760c68787 /src/common/timing.c | |
| parent | 8d9f7c7cb39359d62bf28ef1775b944a7dddd6fb (diff) | |
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
Diffstat (limited to 'src/common/timing.c')
| -rw-r--r-- | src/common/timing.c | 9 |
1 files changed, 4 insertions, 5 deletions
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) |
