• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Efficient object wrappers and GC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Efficient object wrappers and GC
      • From: Alastair Houghton <email@hidden>
References: 
 >Efficient object wrappers and GC (From: Alastair Houghton <email@hidden>)
 >Re: Efficient object wrappers and GC (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Question about NSTreeController/NSOutlineView instance cleanup
  • Next by Date: Re: Efficient object wrappers and GC
  • Previous by thread: Re: Efficient object wrappers and GC
  • Next by thread: Re: Efficient object wrappers and GC
  • Index(es):
    • Date
    • Thread