On Thu, 28 Feb 2013 09:48:02 -0500, Jacob Carlborg <d...@me.com> wrote:

On 2013-02-28 15:31, Steven Schveighoffer wrote:

while(!r.empty)  // inlined to r.front != 0
{
    switch(r.front) // why would another load occur here?
    {
       // no need to check for 0, already done
       ...
    }
}

Don't you have to check for 0 anyway. You could still have more data in the buffer? I doesn't have to be the manually added sentential that is encountered.

You are missing the point. Empty is DEFINED as r.front == 0. Adding a check for 0, would essentially lead to dead code (and technically, the compiler could trim it out).

An important thing about a sentinel input range is that it is not an array -- you cannot maintain or process length, because length is defined by the sentinel. This becomes an advantage when your goal is simply to process every element -- no time wasted updating length.

-Steve

Reply via email to