On Sun, Dec 17, 2000 at 10:01:58PM -0700, Warner Losh wrote:
> In message <[EMAIL PROTECTED]> "Jacques A. Vidrine" writes:
> : I hate to give up a line for
> :
> : if (data)
> : free(data);
> :
> : but neither do I care for ``if (data) free(data);''. I guess if I
> : were writing several statements like that in a single file, I would
> : consider the macro route (e.g. xfree).
>
> No offense, but this strikes me as a premature, sub-micro
> optimization.
None taken. It is however a simple and safe optimization, with no
apparent downsides. It has the same attraction as using bit shifts
instead of multiplication/division, or saving the value from a function
call that will be needed again later, even if you know the function call
is trivial.
> I doubt that you could measure any difference between
> if (foo) free(foo);
> and free(foo);
>
> in the real world.
This is probably correct for most applications.
Nevertheless, I tend to write it that way at times -- maybe because it
seems so natural to me to ask `do I need to free this thing?' -- and
that gets translated directly to code.
--
Jacques Vidrine / [EMAIL PROTECTED] / [EMAIL PROTECTED] / [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message