From 5bbcd2c036dd19d3293d9abc4d44014a5108a5ed Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 23:35:00 +0300 Subject: opt: shrink input event to 48B, pack mouse event to 32B, and shave 2KB off yasl_surface - Compact yasl_mouse_event from 36B to 32B (half a cacheline, 0 holes) - Compact yasl_input_event from 56B to 48B (0 holes) - Reduce yasl_surface by 2,048 bytes (shaving 32 full cachelines per surface) - Optimize UTF-8 sanitize with vectorized validation fast-path - Fast-path MIME prefix match in clipboard transfers --- src/wayland/clipboard.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/wayland') diff --git a/src/wayland/clipboard.c b/src/wayland/clipboard.c index 324644f..0e6ce33 100644 --- a/src/wayland/clipboard.c +++ b/src/wayland/clipboard.c @@ -170,9 +170,12 @@ static struct transfer *start_transfer(struct clipboard *c, int fd, bool sending static const char *match_text_mime(const char *mime) { - if (!strcasecmp(mime, "text/plain;charset=utf-8")) return "text/plain;charset=utf-8"; - if (!strcasecmp(mime, "text/plain;charset=utf8")) return "text/plain;charset=utf8"; - if (!strcasecmp(mime, "text/plain")) return "text/plain"; + if (unlikely(!mime)) return NULL; + if (likely(!strncasecmp(mime, "text/plain", 10))) { + if (!strcasecmp(mime, "text/plain;charset=utf-8")) return "text/plain;charset=utf-8"; + if (!strcasecmp(mime, "text/plain;charset=utf8")) return "text/plain;charset=utf8"; + if (!strcasecmp(mime, "text/plain")) return "text/plain"; + } if (!strcasecmp(mime, "UTF8_STRING")) return "UTF8_STRING"; if (!strcasecmp(mime, "STRING")) return "STRING"; if (!strcasecmp(mime, "TEXT")) return "TEXT"; -- cgit v1.2.3