Which option is faster...

bearophile bearophileHUGS at lycos.com
Mon Aug 5 07:50:26 PDT 2013


jicman:

> How would you make it faster in D1?

Compute std.string.tolower(fext[0]) and put it in a temporary 
variable. And then compare that variable with all your string 
literals. In most cases that's fast enough. If it's not enough, 
you could create a little finite state machine that represents 
your directed acyclic word graph, and uses gotos to jump around 
states. The amount of strings is small, so perhaps there are not 
enough code cache misses to nullify this optimization.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list