[PATCH v2] Re: avoid useless if-before-free tests
Jakub Jelinek
jakub@redhat.com
Tue Mar 8 15:36:00 GMT 2011
On Tue, Mar 08, 2011 at 07:28:37AM -0800, Ian Lance Taylor wrote:
> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>
> >> I found no ChangeLog for libgo and no other libgo-related entries.
> >> I suspect that means I should omit this change because it belongs upstream.
> >
> > Indeed, cf. libgo/README*. I've Cc'ed Ian who maintains this part of
> > GCC.
>
> Yes, libgo is upstream but in any case I'd prefer that you not make the
> change to libgo/runtime/go-select.c. I'm aware that free (NULL) is a
> no-op but I wrote the code that way because it is extremely unlikely
> that allocated_buffer != NULL. I am simply inlining the common case.
> Thanks.
I guess such reason is sometimes legitimate, but it would be nice (and
better for generated code) to make it explicit in that case, i.e.
if (__builtin_expect (allocated_buffer != NULL, 0))
free (allocated_buffer);
could be a sign for anyone coming after Jim that this case is on purpose
and should be left as is.
allocated_buffer != NULL is normally predicted as true, not false.
Jakub
More information about the Java-patches
mailing list