On Thu, 28 Feb 2013 12:02:53 -0500, Walter Bright <newshou...@digitalmars.com> wrote:

On 2/28/2013 7:40 AM, Steven Schveighoffer wrote:
If you look at lexer.c, case 0 is the first test.

No, it is not. It is actually a table lookup - all done in parallel.

     jmp cases[character]


You are comparing the assembly output of your solution with uncompiled D code. Apples and oranges.

Quoting directly from https://github.com/D-Programming-Language/dmd/blob/master/src/lexer.c#L479:

        switch (*p)
        {
            case 0:

As several others have pointed out, an optimizer can (and some do) make this rewrite automatically.

The point is, if the lexer simply requires an input range, and not a sentinel input range, it is more flexible for its input. But when it does get called with a sentinel input range, the optimizer can reap the benefits.

-Steve

Reply via email to