Proposal for SentinelInputRange

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Feb 28 09:00:57 PST 2013


28-Feb-2013 20:52, Walter Bright пишет:
> On 2/28/2013 3:29 AM, Jonathan M Davis wrote:
>> And you were just claiming that the lexer checked the sentinel type in
>> only
>> one place. If that's indeed the case (and I think that it's quite
>> close to
>> being true if it isn't true), then you _wouldn't_ need to use static
>> ifs like
>> this in many places. So, which is it? If you need to check the
>> sentinel often
>> enough that using static ifs is a problem, then it's probably not
>> buying you
>> much of anything over checking empty anyway.
>
> Please, again, examine lexer.c.
>
> For example, look at what happens after line 719. Try 794 in particular.
>
> Now look at line 996 and what follows. Note that there is not a single
> null check there, yet the code is correct and does not run off the end
> of the data.
>
>
>> But my point is that outside of strings or arrays, you're almost
>> certainly
>> stuck with that.
>
> I've given you two examples (lexer and regexp) where you are certainly
> not stuck with that, and those two cases matter.
>

I'll add that when I wrote current std.regex internal VM I've switched 
to the sentinel as terminator of the program instead of checking the 
length. The end result was about 5% of speed up gained back then 
(measured on DMD alone though, other compilers didn't compile it at the 
time).

In the lexer it may help a bit more given the lookahead.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list