Re: Efficient object wrappers and GC
Re: Efficient object wrappers and GC
- Subject: Re: Efficient object wrappers and GC
- From: Quincey Morris <email@hidden>
- Date: Fri, 11 Apr 2008 09:26:21 -0700
On Apr 11, 2008, at 08:07, Michael Ash wrote:
The obvious technique would be to stop trying to make the optimization
implicit and to make it explicit and managed by the caller instead. In
other words, you write your API so that it explicitly returns the same
object every time you call -nextObject, just with a new state. Then
you have a copy method which the caller can use to get a new
unchanging object for the case where he wants to keep one around.
Furthermore, if the "new state" just consists of a pointer to a C
structure, the caller never needs to bother keeping the object around,
but can just keep the structure pointer.
Alternatively, since it's necessary to write a custom NSEnumerator
subclass for this, why not just write a new CEnumerator class that
returns 'nextStruct' instead of 'nextObject'? It's not like
NSEnumerator actually implements any behavior that you can inherit
anyway.
_______________________________________________
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