4x faster strlen with 4 char sentinel

Jay Norwood via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Jun 27 09:22:56 PDT 2016


On Monday, 27 June 2016 at 06:31:49 UTC, Ola Fosheim Grøstad 
wrote:
> Besides there are plenty of other advantages to using a 
> terminating sentinel depending on the use scenario. E.g. if you 
> want many versions of the same tail or if you are splitting a 
> string at white space (overwrite a white space char with a 
> zero).

This strlen2 doesn't require special alignment or casting of char 
pointer types to some larger type. That keeps the strlen2 
implementation fairly simple.

The implementation is only testing one char per increment.  It 
doesn't require the extra xor processing used in some of the 
examples.

I haven't checked if there is a strlen for dchar or wchar, but it 
should also speed up those.






More information about the Digitalmars-d-announce mailing list