<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On 10 June 2013 21:41, Walter Bright <span dir="ltr"><<a href="mailto:walter@digitalmars.com" target="_blank">walter@digitalmars.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
On 6/9/2013 11:29 PM, Don Clugston wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
I'm not sure. That's the number of calls to the constructor of TemplateInstance. I don't understand the code well enough to know<br>
if it can eventually gets merged with an existing TemplateInstance.<br>
If so, then perhaps there's something we could do to prevent them from getting created in the first place if they are duplicates.<br>
<br>
</blockquote>
<br></div>
The template instantiation code is short-circuited if the instantiation already exists. (It's a bad bug if this is broken.)<br><div class=""><div class="h5">
<br></div></div></blockquote><div><br></div><div class="gmail_extra">It's not a compiler bug. It's something more interesting.<br>I counted the number of instantiations in std.algorithm -unittest.<br></div><div><div>
<div class="gmail_extra">635 templates are instantiated, half of them only 1 to 10 times.<br></div><div class="gmail_extra">These ones here cover 70% of the total.<br></div><div class="gmail_extra"><br>70763    isNarrowString<br>
31279    binaryFun<br>24425    isInputRange<br>22308    Unqual<br>15563    startsWith<br>15381    isBidirectionalRange<br>11405    endsWith<br>7861    FormatSpec<br>7277    OriginalType<br>7275    to<br>6723    TypeTuple<br>
5827    defaultInit<br>5713    from<br>5413    isRawStaticArray<br><br></div><div class="gmail_extra">Then,
 the question is, how do we get 71K different types to instantiate 
isNarrowString with? There aren't nearly that many types declared in the
 program!<br></div><div class="gmail_extra">Turns our it's things like:<br></div><br>Zip!(Sequence!("n", Tuple!(ulong)), Sequence!("n", Tuple!(int)), Result, Repeat!(Sequence!("n", Tuple!(int))), Repeat!(Result))<br>
<br></div>So
 we've got a combinatorial explosion of types happening here. I'm sure 
that's true for the other massively-instantiated templates as well. If 
we could avoid this, we would get an order of magnitude improvement in 
memory usage and compilation time.<br> <br></div></div></div></div>