From 12325f6542be8f3ed38600e646d8424c55afc64c Mon Sep 17 00:00:00 2001 From: Bo Date: Tue, 15 Oct 2024 22:22:50 +0300 Subject: [PATCH] pref --- fio-stl.h | 15 +++------------ fio-stl/000 core.h | 15 +++------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/fio-stl.h b/fio-stl.h index 226a0fc..07efaad 100644 --- a/fio-stl.h +++ b/fio-stl.h @@ -1289,7 +1289,9 @@ UTF-8 Support (basic) ***************************************************************************** */ #ifndef FIO_UTF8_ALLOW_IF -#define FIO_UTF8_ALLOW_IF 0 +/* UTF-8 Constant Time? (0 = avoid mis-predictions; 1 = mostly ascii) */ +#define FIO_UTF8_ALLOW_IF 1 + #endif /* Returns the number of bytes required to UTF-8 encoded a code point `u` */ @@ -1391,17 +1393,6 @@ FIO_IFUNC uint32_t fio_utf8_read(char **str) { unsigned len = fio_utf8_char_len(s); *str += len; #if FIO_UTF8_ALLOW_IF - switch (len) { - case 4: - return (((uint32_t)s[0] & 15) << 18) | (((uint32_t)s[1] & 63) << 12) | - (((uint32_t)s[2] & 63) << 6) | ((uint32_t)s[3] & 63); - case 3: - return (((uint32_t)s[0] & 31) << 12) | (((uint32_t)s[1] & 63) << 6) | - ((uint32_t)s[2] & 63); - case 2: return (((uint32_t)s[0] & 63) << 6) | ((uint32_t)s[0] & 63); - case 1: return (uint32_t)*s; - } - return 0; if (!len) return 0; if (len == 1) diff --git a/fio-stl/000 core.h b/fio-stl/000 core.h index 5169b9c..60db8e9 100644 --- a/fio-stl/000 core.h +++ b/fio-stl/000 core.h @@ -1252,7 +1252,9 @@ UTF-8 Support (basic) ***************************************************************************** */ #ifndef FIO_UTF8_ALLOW_IF -#define FIO_UTF8_ALLOW_IF 0 +/* UTF-8 Constant Time? (0 = avoid mis-predictions; 1 = mostly ascii) */ +#define FIO_UTF8_ALLOW_IF 1 + #endif /* Returns the number of bytes required to UTF-8 encoded a code point `u` */ @@ -1354,17 +1356,6 @@ FIO_IFUNC uint32_t fio_utf8_read(char **str) { unsigned len = fio_utf8_char_len(s); *str += len; #if FIO_UTF8_ALLOW_IF - switch (len) { - case 4: - return (((uint32_t)s[0] & 15) << 18) | (((uint32_t)s[1] & 63) << 12) | - (((uint32_t)s[2] & 63) << 6) | ((uint32_t)s[3] & 63); - case 3: - return (((uint32_t)s[0] & 31) << 12) | (((uint32_t)s[1] & 63) << 6) | - ((uint32_t)s[2] & 63); - case 2: return (((uint32_t)s[0] & 63) << 6) | ((uint32_t)s[0] & 63); - case 1: return (uint32_t)*s; - } - return 0; if (!len) return 0; if (len == 1)