<p><br>
On 23 Feb 2013 20:25, "jerro" <<a href="mailto:a@a.com">a@a.com</a>> wrote:<br>
>><br>
>> BTW, I think the clearest remains my generator proposal:<br>
>> string randomString =<br>
>>     fastGenerator!(() => letters[uniform(0, $)]).take(9).array;<br>
><br>
><br>
> If the goal was to replace iota(n).map, it may be better to just have something like:<br>
><br>
>     generate!(() => letters[uniform(0, $)])(n).array<br>
><br>
> But of course, your fastGenerator is more general. I personally don't often have a need to generate an infinite range in this way, but other people may.<br>
><br>
><br>
>> Any chance you could tell me how it fares in your bench?<br>
><br>
><br>
> I used this code:<br>
><br>
> auto tmp = FastGenerator!(() => letters[uniform(0, $)])().take(n).array;<br>
><br>
> When I build it with GDC, it performs about the same as the code that uses iota and map. When I build it with DMD it's about 10% slower than the code that uses iota and map. It seems that DMD fails to inline the lambda in this case.<br>

></p>
<p>That is deliberate on gdc's part to mark all lambdas as inlineable as most just do one computation and don't require any custom static chain built to access locals in parent functions.  :)<br></p>
<p>Regards<br>
----<br>
Iain Buclaw</p>
<p>*(p < e ? p++ : p) = (c & 0x0f) + '0';<br>
</p>