02-Mar-2013 22:15, Dmitry Olshansky пишет:
02-Mar-2013 22:09, Namespace пишет:
No-no and no.
Just translate list of keywords/types to a bunch of switch-cases that
will give you near optimal performance. Use CTFE to construct that
string of D code.
In fact I proposed to do just 2 levels of switches: first switch by
length then by first char.
I don't understand.
You don't mean something like:
switch (value) {
case "if": isKeyword = true; break;
...
right?
No.
switch(value.length)
case 2:
switch(value[0])
{
case 'i':
switch(value[1]){
case 'f':
return value.length == 2;
return true;
I edited the post to include length switch before per-char switch.
case ...
...
}
...
case 3:
...
}
--
Dmitry Olshansky