Skip to content

Commit

Permalink
pref
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Oct 15, 2024
1 parent db568bc commit 12325f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
15 changes: 3 additions & 12 deletions fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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` */
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 3 additions & 12 deletions fio-stl/000 core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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` */
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 12325f6

Please sign in to comment.