[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Remove useless if-before-free and if-before-xfree tests
From: |
Stephen J. Turnbull |
Subject: |
Re: Remove useless if-before-free and if-before-xfree tests |
Date: |
Tue, 30 Jun 2009 08:43:58 +0900 |
Jim Meyering writes:
> Kim F. Storm wrote:
> > Jim Meyering <address@hidden> writes:
> >> I removed a bunch of these last year.
> >> Since then, a few have snuck back in, so here's another round.
> >> I've just committed the following two change sets:
> >
> > I haven't looked specifically at the changes, but a test before xfree
> > may not be useless performance-wise if the normal case is "ptr is NULL".
These "normally NULL" cases are likely only in "last chance" cleanup,
which should be outside the loop.
> Hi Kim,
>
> If adding that extra "if" test-before-free leads to a measurable
> performance improvement, please let me know. I've removed hundreds
> of such tests in many projects, and so far no one has taken the time
> (or been able?) to demonstrate such a thing.
>
> Besides, even if there is a measurable performance difference, in my book,
> the cleaner code trumps what can only be a negligible performance hit.
"inline" is your friend. If you don't trust GCC (and on this kind of
thing, who does? :-), you can force xfree to inline the test by
defining it as a macro.