Proposal for SentinelInputRange
Walter Bright
newshound2 at digitalmars.com
Thu Feb 28 14:00:06 PST 2013
On 2/28/2013 9:25 AM, Steven Schveighoffer wrote:
> On Thu, 28 Feb 2013 12:00:48 -0500, Walter Bright <newshound2 at digitalmars.com>
> wrote:
>
>> On 2/28/2013 6:31 AM, Steven Schveighoffer wrote:
>>> If this doesn't translate to the same code, I don't know why not.
>>
>> Try it and see with your favorite C compiler.
>
> A sample case of 1 does not prove it's not possible, or explain why those
> optimizers don't take that step. A valid response would be to give a case why
> an optimizer COULDN'T make that leap.
No, it is not. DMD is compiled with real compilers, not abstract "sufficiently
smart compilers".
>> Then try the lookahead cases I also posted.
>
> You have already stated it gets changed into a jump table.
Please, please listen to what I write. This is very frustrating. The code in
lexer.c is there for all to see, and it amply illustrates everything I'm saying.
For example, this code does not get translated into a jump table:
case '+':
p++;
if (*p == '=')
{ p++;
t->value = TOKaddass;
}
else if (*p == '+')
{ p++;
t->value = TOKplusplus;
}
else
t->value = TOKadd;
return;
> Such an optimization
> seems possible to me, even with the != 0 check outside the switch, even if not
> all C compilers employ it.
It doesn't matter if it is theoretically possible if the compilers we need to
use do not do it.
More information about the Digitalmars-d
mailing list