Function strlen

Source
pub unsafe fn strlen<T>(ptr: *const T) -> usize
where T: ValueType,
Expand description

Calculates the length of a null-terminated string pointed to by ptr, returning the number of bytes before the null terminator.

§Safety

This function is unsafe because it dereferences a raw pointer, it will not work on 0 length strings, they MUST be null-terminated.

Uses AVX2 if compiled with flags otherwise SSE2 if available, failng that, libc::strlen. Interesting benchmarks resuls: It’s faster than my constant time strlen for dirents for small strings, but after 32 bytes, it becomes slower. It is also faster than the libc implementation but only for size below 128…?wtf.