A virtual function returning a small structure - return value vs output parameter?
<p>I have a virtual function in a hotspot code that needs to return a structure as a result. I have these two options:</p>

<pre><code>virtual Vec4 generateVec() const = 0; // return value

virtual void generateVec(Vec4&amp; output) const = 0; // output parameter
</code></pre>

<p>My question is, is there generally any difference in the performance of these functions? I'd assume the second one is faster, because it does not involve copying data on the stack. However, the first one is often much more convenient to use. If the first one is still slightly slower, would this be measurable at all? Am I too obsessed :)</p>

<p>Let me stress that that this function will be called millions of times every second, but also that the size of the structure Vec4 is small - 16 bytes.</p>
