How is it possible that countUntil() generates a jump-table when the hayStack is a compile time array?

realhet real_het at hotmail.com
Sat Oct 1 16:39:29 UTC 2022


On Saturday, 1 October 2022 at 13:49:12 UTC, H. S. Teoh wrote:
> On Sat, Oct 01, 2022 at 01:20:08PM +0000, realhet via 
> Digitalmars-d-learn wrote:

It is very good to know. Thank You for the confirmation. Indeed 
it is really clever.

I wrote a parser only to parse the structural elements of Dlang 
using template string[] parameters to feed tokens for the 
specialized parser functions recursively(!). And it unrolled 
everything into jump tables. Insane :D

The only successful optimization I made was using PCMPESTRI 
instruction for skipping 16 bytes of text when there is no match 
found in a compile time constant 16 element character set.
I expected like 10x speedup because of PCMPESTRI. But I only got 
2x. I thought I was competing with poor linear searches only, but 
little I knew...



More information about the Digitalmars-d-learn mailing list