Suggestion to improve phobos std.string.icmp function

Chad J gamerChad at _spamIsBad_gmail.com
Tue Jul 18 17:25:59 PDT 2006


Lionello Lunesu wrote:
> Hi,
> 
> Beware that using a char to index into an array can cause access 
> violation if the char's negative. You'll get [-1] and such. cast it to a 
> byte.
> 
> Otherwise, seems like a good optimization. Either your code, or some 
> more complicate function using the tolower from std.uni. Will be tricky 
> to optimize that one.
> 
> L.

I took a look at std.uni.toUniLower.  It looks susceptible to the same 
optimization.  All but 2 if those range checks could be eliminated with 
a 2732 byte long table (an array of ushorts, going out to 0x0556). 
Getting rid of those last two ranges seems harder as it would require a 
much bigger table, well at least the last one (0xFF21 <= x <= 0xFF3A) 
would require a big table to include it.  There would need to be another 
2830 byte long table to handle toUniUpper as well, if that's desired. 
I'd use the current code in a the table generator that would be called 
at starttime (no bloat on the exe).  Just gotta know if the memory loss 
from the tables is acceptable.

Anyhow, I'm not going to write it and benchmark it now because I really 
should be plugging away at my arm-wince-pe port of D.  I'm getting 
distracted as usual :)



More information about the Digitalmars-d mailing list