Subject: Re: libssh2 master 37624b6 sftp_attrsize: converted function to a macro

Re: libssh2 master 37624b6 sftp_attrsize: converted function to a macro

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Wed, 28 Apr 2010 01:30:21 +0100

libssh2_at_git.stuge.se wrote:
> sftp_attrsize: converted function to a macro

> This way, the macro can evaluate a static number at compile time
> for two out of four uses, and it probably runs faster for the
> other two cases too.

Oh please no.

These kind of hand optimisations are almost always useless. Was there
any other reason for the conversion except performance? If not, was
there a benchmark to show this was a bottleneck and the macro fixed
it?

Time and time again people try this type of thing without realising
that compilers and architectures make it almost impossible to predict
if there is any speedup in practice. Compilers play with your code
and, more importantly, different processor architectures do strange
things that make execution bear no resemblance to how you imagined it
would happen.

In practice, this may even run slower.

Alex
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-04-28