[libvirt] [PATCH] Reusing the result of virArchFromHost instead of calling it multiple times

Eric Blake eblake at redhat.com
Tue Apr 9 22:04:40 UTC 2013


On 04/09/2013 12:38 AM, Tal Kain wrote:
> On Mon, Apr 8, 2013 at 4:32 PM, Daniel P. Berrange <berrange at redhat.com>wrote:
> 
>> On Mon, Apr 08, 2013 at 03:33:07PM +0300, Tal Kain wrote:
>>> Signed-off-by: Tal Kain <tal.kain at ravellosystems.com>
>>> ---
>>>  src/qemu/qemu_capabilities.c |   13 +++++++------
>>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> What is the motivation for doing this ?  it just looks like
>> overkill to me, since virArchFromHost isn't really an
>> expensive method to invoke.
>>

> This patch's motivation is not about making this function faster.
> Even if virArchFromHost isn't expensive, It seemed to me like there is no
> good reason for calling it 3 times at the same context, It is just
> unnecessary.
> Why using a local variable instead of calling the same function three times
> is an overkill?

Personally, I don't think the patch is too bad, and I'll probably apply
it unless Dan can give a stronger objection.

> 
>>From my perspective, by calling it just once I'm making it easier for a
> reader to understand the usage of this function without reading its code.

A good compiler will already factor out invariant calls; but we don't
use enough annotations to tell the compiler that virArchFromHost is
invariant.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130409/ec872575/attachment-0001.sig>


More information about the libvir-list mailing list