On Thursday, 28 February 2013 at 04:57:08 UTC, Walter Bright wrote:
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.

If the range define empty with something like front == sentinel, the inliner should kick in a reduce the whole stuff to only one read, no ?

Reply via email to