On Sunday, 26 June 2016 at 16:59:54 UTC, David Nadlinger wrote:
Please keep general discussions like this off the announce
list, which would e.g. be suitable for announcing a fleshed out
collection of high-performance string handling routines.
A couple of quick hints:
- This is not a correct implementation of strlen, as it
already assumes that the array is terminated by four zero
bytes. That iterating memory with a stride of 4 instead of 1
will be faster is a self-evident truth.
- You should be benchmarking against a "proper" SIMD-optimised
This is more of just an observation that the choice of the single
zero sentinel for C string termination comes at a cost of 4x
strlen speed vs using four terminating zeros.
I don't see a SIMD strlen implementation in the D libraries.
The strlen2 function I posted works on any string that is
terminated by four zeros, and returns the same len as strlen in
that case, but much faster.
How to get strings initialized with four terminating zeros at
compile time is a separate issue. I don't know the solution,
else I might consider doing more with this.