| 83 | // Returns the length of a string, denoted by the first occurrence |
| 84 | // of a null terminator. |
| 85 | template <typename T> LIBC_INLINE size_t string_length(const T *src) { |
| 86 | #ifdef LIBC_COPT_STRING_UNSAFE_WIDE_READ |
| 87 | // Unsigned int is the default size for most processors, and on x86-64 it |
| 88 | // performs better than larger sizes when the src pointer can't be assumed to |
| 89 | // be aligned to a word boundary, so it's the size we use for reading the |
| 90 | // string a block at a time. |
| 91 | if constexpr (cpp::is_same_v<T, char>) |
| 92 | return string_length_wide_read<unsigned int>(src); |
| 93 | #endif |
| 94 | size_t length; |
| 95 | for (length = 0; *src; ++src, ++length) |
| 96 | ; |
| 97 | return length; |
| 98 | } |
| 99 | |
| 100 | template <typename Word> |
| 101 | LIBC_INLINE void *find_first_character_wide_read(const unsigned char *src, |
no outgoing calls
no test coverage detected