If the tag name in the XML document file contains period, pRoot always be NULL. I think period can be used as the tag name as long as it is not the the first character. (so “.text” can’t be but “v1.0” can be)
A table is used in the non-unicode version, and this function is called _slow because it’s the routine used to populate the table.
I’d be very disappointed if a modern compiler didn’t manage to make such a simple if statement as fast as a switch statement. Also, bear in mind that the CharacterFunctions call is checking unicode characters, not just western letters, and that’s not something that you could inline very easily.
As for the if, the compiler might make it switch’ish, but I would not really think so for that few things. Switch’s have a speed hit due to translating the params into a jump location when the parameters are not increasing uniformly, such as how that one would be. However, a switch statement like:
select(c):
case 0:
return false;
case 1:
return false;
case 2:
return false;
/* snip */
case 'a':
return true;
case 'b':
return true;
case 'c':
return true;
/* snip */
case '_':
return true;
/* snip */
case 255:
return false;
}
will create the fastest possible switch statement since it generates code that just has a multiply and offset, and returns the value at that location.
A bit more typing that would be, but if interested in speed improvements at all, meh…
Although a static const array of size 256 bytes (bool) so you could just do something like XMLIdentifiers[somechar] would return a true/false for if it is valid and would vastly be the easiest to optimize for the compiler.