Having a separate array with $prefixLengths allows to skip one strlen() further down.
It is yet unclear if this actually gives an advantage (need to benchmark)