discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUstep.h (was: Re: Setter Gettor method style)


From: Nicola Pero
Subject: Re: GNUstep.h (was: Re: Setter Gettor method style)
Date: Wed, 7 Aug 2002 12:37:10 +0100 (BST)

> And why not just
> #define TEST_AUTORELEASE(object) [object autorelease]

This is what AUTORELEASE(object) does
 
> Since methods sent to nil are really not a bad thing.
> 
> Oh sure in the case where the object is nil you have a function call where
> you could have gotten away with just a branch instruction, but the
> objc_send_msg is going to check for nil again anyway.

Yes - you are right - people should use AUTORELEASE(object) in normal
cases.  TEST_AUTORELEASE(object) is there just for cases in which
efficiency might be very relevant, and you explicitly ask for the
autorelease method to be avoided if the object is nil.  There is very
rarely a need for it (and you can always do it manually, code like if
(object != nil) { AUTORELEASE (object)})

By the way, it looks like it should be 

#define TEST_AUTORELEASE(object)        ({ object != nil ? [object autorelease] 
: nil })

rather than

#define TEST_AUTORELEASE(object)        ({ if (object) [object autorelease]; })

otherwise 

object1 = TEST_AUTORELEASE(object);

would not work.  Not sure that anyone cares, but I noticed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]