• 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: NSEnumerator retaining objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEnumerator retaining objects?


  • Subject: Re: NSEnumerator retaining objects?
  • From: Shaun Wexler <email@hidden>
  • Date: Wed, 9 Mar 2005 04:26:10 -0800

On Mar 9, 2005, at 3:42 AM, j o a r wrote:

On 2005-03-09, at 12.25, Shaun Wexler wrote:

Let's get rid of performance killers wherever possible! I'd rather see NSEnumerator _not_ retain the collection, nor retain/autorelease the returned objects. It's already documented not to be thread-safe to enumerate a mutable collection, and if you have to manipulate one using mutexes, retains would then be performed by your thread-safe accessor methods.

How is this thread in any way related to thread safety concerns and mutability? You're not allowed to mutate a collection while it's used by an enumerator, so it doesn't really matter for this discussion if the collection is mutable or not.

It is completely related to it, because NSEnumerator operates on mutable collections and may get called from multiple threads. My point is that retain/autorelease performed by NSEnumerator is redundant; returning a pointer to an object already retained by its collection is unnecessary within the current thread's context, WRT -nextObject. Going beyond a single-threaded app's needs may require additional measures to manage object lifetimes. A properly written application will not be broken if the retain/autorelease pair were removed from the NSEnumerator nextObject implementation, and most Cocoa apps should benefit from the performance increase.
--
Shaun Wexler
MacFOH
http://www.macfoh.com


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSEnumerator retaining objects?
      • From: j o a r <email@hidden>
References: 
 >Re: NSEnumerator retaining objects? (From: James Bucanek <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: mmalcolm crawford <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: Shaun Wexler <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: j o a r <email@hidden>)

  • Prev by Date: How to create a window with a border
  • Next by Date: Re: NSEnumerator retaining objects?
  • Previous by thread: Re: NSEnumerator retaining objects?
  • Next by thread: Re: NSEnumerator retaining objects?
  • Index(es):
    • Date
    • Thread