MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / string_length

Function string_length

system/lib/llvm-libc/src/string/string_utils.h:85–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83// Returns the length of a string, denoted by the first occurrence
84// of a null terminator.
85template <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
100template <typename Word>
101LIBC_INLINE void *find_first_character_wide_read(const unsigned char *src,

Callers 15

oneshot_hashMethod · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85
LLVM_LIBC_FUNCTIONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected