Proposal for SentinelInputRange
Walter Bright
newshound2 at digitalmars.com
Wed Feb 27 20:56:38 PST 2013
On 2/27/2013 8:53 PM, Zach the Mystic wrote:
> My understanding of the logic of Sentinel Ranges so far is that switch
> statements and other control flow can proceed eagerly, because "go" values can
> be checked before the sentinel "stop" value, and "!empty" is known implicitly. I
> don't know exactly where the speed benefits of having a single "stop" value
> known at compile time come from.
>
> Is this design focused more on your knowledge of how the compiler optimizes
> machine code, or on something which can be grasped at a higher level?
Take a look at lexer.c.
With an InputRange, reading a character from a 0 terminated string requires two
read operations. A SentinalInputRange requires only one.
More information about the Digitalmars-d
mailing list