summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-11 23:35:00 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-11 23:35:00 +0300
commit5bbcd2c036dd19d3293d9abc4d44014a5108a5ed (patch)
tree2ca0c8f4df7527a9596ef6fb011a6d2c0f742b9e /src/common
parent5530c662bb53837d64a154e3b580d41adb6cc8b9 (diff)
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
Diffstat (limited to 'src/common')
-rw-r--r--src/common/utf8.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/utf8.c b/src/common/utf8.c
index 7f2e6f1..1d4cf13 100644
--- a/src/common/utf8.c
+++ b/src/common/utf8.c
@@ -54,10 +54,17 @@ bool yasl_utf8_validate(const char *str, size_t len)
char *yasl_utf8_sanitize_dup(const char *str)
{
- if (!str) return NULL;
+ if (unlikely(!str)) return NULL;
size_t len = strlen(str);
+ if (likely(yasl_utf8_validate(str, len))) {
+ char *out = malloc(len + 1);
+ if (unlikely(!out)) return NULL;
+ memcpy(out, str, len + 1);
+ return out;
+ }
+
char *out = malloc(len + 1);
- if (!out) return NULL;
+ if (unlikely(!out)) return NULL;
const unsigned char *p = (const unsigned char *)str;
size_t o = 0;