Which option is faster...
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Aug 5 08:29:40 PDT 2013
On Mon, Aug 05, 2013 at 04:47:36PM +0200, dennis luehring wrote:
> > Ok, how would you make it faster?
>
> i don't see a better solution here - how to reduce ONE lowercase and
> SOME compares in any way? (i dont think a hash or something will
> help) but i know that anything like your continue-party is worth
> nothing (feels a little bit like script-kiddies "do it with
> assembler that would it make million times faster" blabla)
If you really want optimal performance, use std.regex:
import std.regex;
auto reExtMatch = ctRegex!(`doc|docx|exe|...`, "i");
foreach (...) {
if (fext[0].match(reExtMatch))
continue;
}
The regex is set up to ignore case (the "i" flag), and is compiled at
compile-time to generate optimal matching code for the given list of
extensions. To get any faster than this, you'll have to hand-optimize or
write in assembly. :)
T
--
Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. -- Gene Wirchenko
More information about the Digitalmars-d-learn
mailing list