<p><br>
On Sep 29, 2012 2:55 PM, "Jacob Carlborg" <<a href="mailto:doob@me.com">doob@me.com</a>> wrote:<br>
><br>
> On 2012-09-28 19:47, Peter Alexander wrote:<br>
><br>
>> A note on your Vector implementation. Currently you use the vector<br>
>> operators, e.g.<br>
>><br>
>>      Vector!(T,size) opAddAssign (Vector!(T,size) v)<br>
>>      body<br>
>>      {<br>
>>          arrayof[] += v.arrayof[];<br>
>>          return this;<br>
>>      }<br>
>><br>
>> This is fine for large vectors, but (correct me if I'm wrong), your<br>
>> vector class appears to be designed for small vectors. Those vector ops<br>
>> currently call a asm optimised function that uses SIMD instructions in a<br>
>> loop - it works well for larger vectors with hundreds of elements, but<br>
>> for small vectors it's significantly faster to just use:<br>
>><br>
>> foreach (i; 0..size)<br>
>>      arrayof[i] += v.arrayof[i];<br>
><br>
><br>
> Isn't the whole point of the array operators that it gives the compiler more semantic understanding of the code. Just as a foreach-loop does compared to a for-loop. So the compiler should be able to optimize this and generated the most optimal code. But the compiler might not be that good.<br>

><br>
> -- <br>
> /Jacob Carlborg<br>
+1<br>
</p>