Proposal for SentinelInputRange

Walter Bright newshound2 at digitalmars.com
Thu Feb 28 17:57:42 PST 2013


On 2/28/2013 5:00 PM, deadalnix wrote:
> On Friday, 1 March 2013 at 00:34:25 UTC, Walter Bright wrote:
>>> I just don't see how you're going to get a
>>> performance gain from much of anything other than strings.
>>
>> I gave you other examples already. We're just going around in circles.
>
> You didn't posted a single example that wasn't optimized by LLVM.

Search for [1] in lexer.c, i.e. lookahead cases, although these are less important.

I admit I was surprised that LLVM did that, though the other compilers did not. 
There are some lingering issues with ordering. The sentinel is going to be the 
rare case, and you'd often want to sort the cases so that the most likely ones 
are tested first (if it doesn't all go into a jump table indexed by the value).

> I do understand that some compiler may not do the optimization, but it is show
> already that this is clearly possible and in fact done. That is not an
> theoretical improvement.
>
> I don't see the point in creating a new type of range simply because some
> compiler don't optimize properly.

It's a good point.


More information about the Digitalmars-d mailing list