On 2/6/18 12:35 AM, Dmitry Olshansky wrote:
On Tuesday, 6 February 2018 at 04:35:42 UTC, Steven Schveighoffer wrote:
On 2/5/18 11:09 PM, psychoticRabbit wrote:
On Monday, 5 February 2018 at 21:27:57 UTC, H. S. Teoh wrote:

Comment out the call to `regex()`, and I get:

------
real    0m0.285s
user    0m0.262s
sys     0m0.023s
------


regex is not the only one I avoid..

how long you think this takes to compile?
(try ldc2 too ..just for laughs ;-)

----
import std.net.isemail;

void main()
{
     auto checkEmail = "[email protected]".isEmail();
}
----

I was surprised at this, then I looked at the first line of isEmail:

    static ipRegex = ctRegex!(`\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}`~

`(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$`.to!(const(Char)[]));

So it's really still related to regex.


That’s really bad idea - isEmail is template so the burden of freaking slow ctRegex is paid on per instantiation basis. Could be horrible with separate compilation.

Obviously it is horrible. On my mac, it took about 2.5 seconds to compile this one line.

I'm not sure how to fix it though... I suppose you could make it 3 overloads, but this defeats a lot of the purpose of having templates in the first place.

-Steve

Reply via email to