Re: Zeroing out instance variables
Re: Zeroing out instance variables
- Subject: Re: Zeroing out instance variables
- From: Charles Srstka <email@hidden>
- Date: Sat, 17 Apr 2010 16:01:36 -0500
On Apr 17, 2010, at 8:34 AM, Ben Haller wrote:
>> Lastly, if your objects are so simple (direct subclasses or NSObject, no pointer ivars, etc.), have you considered using plain C structs instead of objects? Or C++ objects and collections? I'm not saying you necessarily should use those, but you should consider them if performance is so critical and you're bending over backward to work against the normal Cocoa way.
>
> Yeah, I thought about that a lot, actually. It's a weird situation, but I really do want and use inheritance and dynamic message dispatch and so forth. It only comes into play a few times in the entire lifetime of each individual object, but at those few crucial junctures, it would be a huge PITA to be doing things the struct way. C++ hadn't occurred to me, but I'm not fond of the language and don't really want to open that can of worms; to me, that would be uglier than what I'm doing now, in fact. Is there a reason that I'm missing, why that would be a good solution?
How about just giving your object only one instance variable, which is a pointer to a C struct, with all the object’s accessor methods pointing to elements in the struct? Then, all you’d have to do would be to swap out the struct for another one, or zero the struct. No runtime hacking, no assumptions about the internals of the object format.
Charles_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden