std.regex performance

bearophile bearophileHUGS at lycos.com
Wed Feb 8 14:46:32 PST 2012


David Nadlinger:

> Could it be that you are rebuilding the regex engine on every iteration 
> here?

This isn't the first time I see this problem.
CPython caches the RE engines to avoid this problem, so after the first time you use it, it doesn't create the same engine again and again.

Another solution is to change the API, and use a long and ugly function name like buildREengine() that makes it clear to the user that it's better to pull it out of loops :-)

Bye,
bearophile


More information about the Digitalmars-d mailing list